mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Simplified shell context creation.
This commit is contained in:
@@ -175,7 +175,7 @@ namespace Orchard.Setup.Services {
|
||||
// Creating a standalone environment.
|
||||
// in theory this environment can be used to resolve any normal components by interface, and those
|
||||
// components will exist entirely in isolation - no crossover between the safemode container currently in effect.
|
||||
using (var environment = _orchardHost.CreateStandaloneEnvironment(shellSettings, StandaloneEnvironmentOptions.RunningEnvironment)) {
|
||||
using (var environment = _orchardHost.CreateStandaloneEnvironment(shellSettings)) {
|
||||
try {
|
||||
executionId = CreateTenantData(context, environment);
|
||||
}
|
||||
|
@@ -92,13 +92,13 @@ namespace Orchard.Environment {
|
||||
EndRequest();
|
||||
}
|
||||
|
||||
IWorkContextScope IOrchardHost.CreateStandaloneEnvironment(ShellSettings shellSettings, StandaloneEnvironmentOptions options) {
|
||||
IWorkContextScope IOrchardHost.CreateStandaloneEnvironment(ShellSettings shellSettings) {
|
||||
Logger.Debug("Creating standalone environment for tenant {0}", shellSettings.Name);
|
||||
|
||||
MonitorExtensions();
|
||||
BuildCurrent();
|
||||
|
||||
var shellContext = CreateShellContext(shellSettings, options);
|
||||
var shellContext = CreateShellContext(shellSettings);
|
||||
var workContext = shellContext.LifetimeScope.CreateWorkContextScope();
|
||||
return new StandaloneEnvironmentWorkContextScopeWrapper(workContext, shellContext);
|
||||
}
|
||||
@@ -143,7 +143,7 @@ namespace Orchard.Environment {
|
||||
if (allSettings.Any()) {
|
||||
Parallel.ForEach(allSettings, settings => {
|
||||
try {
|
||||
var context = CreateShellContext(settings, StandaloneEnvironmentOptions.None);
|
||||
var context = CreateShellContext(settings);
|
||||
ActivateShell(context);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
@@ -195,14 +195,14 @@ namespace Orchard.Environment {
|
||||
/// <summary>
|
||||
/// Creates a shell context based on shell settings.
|
||||
/// </summary>
|
||||
private ShellContext CreateShellContext(ShellSettings settings, StandaloneEnvironmentOptions options) {
|
||||
if (settings.State != TenantState.Uninitialized || options.Running) {
|
||||
Logger.Debug("Creating shell context for tenant {0}.", settings.Name);
|
||||
return _shellContextFactory.CreateShellContext(settings);
|
||||
private ShellContext CreateShellContext(ShellSettings settings) {
|
||||
if (settings.State == TenantState.Uninitialized || settings.State == TenantState.Invalid) {
|
||||
Logger.Debug("Creating shell context for tenant {0} setup.", settings.Name);
|
||||
return _shellContextFactory.CreateSetupContext(settings);
|
||||
}
|
||||
|
||||
Logger.Debug("Creating shell context for tenant {0} setup.", settings.Name);
|
||||
return _shellContextFactory.CreateSetupContext(settings);
|
||||
|
||||
Logger.Debug("Creating shell context for tenant {0}.", settings.Name);
|
||||
return _shellContextFactory.CreateShellContext(settings);
|
||||
}
|
||||
|
||||
private void SetupExtensions() {
|
||||
@@ -289,7 +289,7 @@ namespace Orchard.Environment {
|
||||
// is this is a new tenant ? or is it a tenant waiting for setup ?
|
||||
if (shellContext == null || settings.State == TenantState.Uninitialized) {
|
||||
// create the Shell
|
||||
var context = CreateShellContext(settings, StandaloneEnvironmentOptions.None);
|
||||
var context = CreateShellContext(settings);
|
||||
|
||||
// activate the Shell
|
||||
ActivateShell(context);
|
||||
|
@@ -1,6 +1,5 @@
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.ShellBuilders;
|
||||
using Orchard.Localization;
|
||||
|
||||
namespace Orchard.Environment {
|
||||
public interface IOrchardHost {
|
||||
@@ -31,6 +30,6 @@ namespace Orchard.Environment {
|
||||
/// Can be used to build an temporary self-contained instance of a shell's configured code.
|
||||
/// Services may be resolved from within this instance to configure and initialize its storage.
|
||||
/// </summary>
|
||||
IWorkContextScope CreateStandaloneEnvironment(ShellSettings shellSettings, StandaloneEnvironmentOptions options = null);
|
||||
IWorkContextScope CreateStandaloneEnvironment(ShellSettings shellSettings);
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +0,0 @@
|
||||
namespace Orchard.Environment {
|
||||
public class StandaloneEnvironmentOptions {
|
||||
public static readonly StandaloneEnvironmentOptions None = new StandaloneEnvironmentOptions();
|
||||
public static readonly StandaloneEnvironmentOptions RunningEnvironment = new StandaloneEnvironmentOptions {Running = true};
|
||||
public bool Running { get; set; }
|
||||
}
|
||||
}
|
@@ -155,7 +155,6 @@
|
||||
<Compile Include="Data\Migration\Schema\DropUniqueConstraintCommand.cs" />
|
||||
<Compile Include="Environment\Extensions\Models\LifecycleStatus.cs" />
|
||||
<Compile Include="Environment\ShellBuilders\ICompositionStrategy.cs" />
|
||||
<Compile Include="Environment\StandaloneEnvironmentOptions.cs" />
|
||||
<Compile Include="IBackgroundHttpContextFactory.cs" />
|
||||
<Compile Include="Mvc\Updater.cs" />
|
||||
<Compile Include="Recipes\Models\ConfigurationContext.cs" />
|
||||
|
Reference in New Issue
Block a user