ShellContext IShellContextFactory.CreateSetupContext(ShellSettings settings) { _logger.LogDebug("No shell settings available. Creating shell context for setup"); var descriptor = new ShellDescriptor { SerialNumber = -1, Features = new[] { new ShellFeature { Name = "Orchard.Logging.Console" }, new ShellFeature { Name = "Orchard.Setup" }, }, }; var blueprint = _compositionStrategy.Compose(settings, descriptor); var provider = _shellContainerFactory.CreateContainer(settings, blueprint); return new ShellContext { Settings = settings, Blueprint = blueprint, LifetimeScope = provider, Shell = provider.GetService<IOrchardShell>() }; }
public static IEnumerable<FeatureDescriptor> EnabledFeatures(this IExtensionManager extensionManager, ShellDescriptor descriptor) { return extensionManager.AvailableFeatures().Where(fd => descriptor.Features.Any(sf => sf.Name == fd.Id)); }
public string Setup(SetupContext context) { string executionId = Guid.NewGuid().ToString(); // The vanilla Orchard distibution has the following features enabled. string[] hardcoded = { // Framework "Orchard.Hosting", // Core "Settings", // Test Modules "Orchard.Demo", "Orchard.Test1" }; context.EnabledFeatures = hardcoded.Union(context.EnabledFeatures ?? Enumerable.Empty<string>()).Distinct().ToList(); var shellSettings = new ShellSettings(_shellSettings); if (string.IsNullOrEmpty(shellSettings.DataProvider)) { shellSettings.DataProvider = context.DatabaseProvider; shellSettings.DataConnectionString = context.DatabaseConnectionString; shellSettings.DataTablePrefix = context.DatabaseTablePrefix; } // TODO: Add Encryption Settings in var shellDescriptor = new ShellDescriptor { Features = context.EnabledFeatures.Select(name => new ShellFeature { Name = name }) }; // 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 // must mark state as Running - otherwise standalone enviro is created "for setup" shellSettings.State = TenantState.Running; // TODO: Remove and mirror Orchard Setup shellSettings.RequestUrlHost = _httpContextAccessor.HttpContext.Request.Host.Value; shellSettings.DataProvider = "InMemory"; _shellSettingsManager.SaveSettings(shellSettings); return executionId; }