public ShellSettingsManager(IConfiguration applicationConfiguration, IShellsConfigurationSources tenantsConfigSources, IShellConfigurationSources tenantConfigSources, IShellsSettingsSources settingsSources)
 {
     this._semaphore = new SemaphoreSlim(1);
     base();
     this._applicationConfiguration = applicationConfiguration;
     this._tenantsConfigSources     = tenantsConfigSources;
     this._tenantConfigSources      = tenantConfigSources;
     this._settingsSources          = settingsSources;
     return;
 }
Beispiel #2
0
 public ShellSettingsManager(
     IConfiguration applicationConfiguration,
     IShellsConfigurationSources tenantsConfigSources,
     IShellConfigurationSources tenantConfigSources,
     IShellsSettingsSources settingsSources)
 {
     _applicationConfiguration = applicationConfiguration;
     _tenantsConfigSources     = tenantsConfigSources;
     _tenantConfigSources      = tenantConfigSources;
     _settingsSources          = settingsSources;
 }
        public ShellSettingsManager(
            IConfiguration applicationConfiguration,
            IShellsConfigurationSources configurationSources,
            IShellConfigurationSources tenantConfigSources,
            IShellsSettingsSources settingsSources,
            IOptions <ShellOptions> options)
        {
            // TODO: Can be removed when going to RC.
            var appDataPath = options.Value.ShellsApplicationDataPath;

            _tenantsContainerPath = Path.Combine(appDataPath, options.Value.ShellsContainerName);

            _tenantConfigSources = tenantConfigSources;
            _settingsSources     = settingsSources;

            var lastProviders = (applicationConfiguration as IConfigurationRoot)?.Providers
                                .Where(p => p is EnvironmentVariablesConfigurationProvider ||
                                       p is CommandLineConfigurationProvider)
                                .ToArray();

            var configurationBuilder = new ConfigurationBuilder()
                                       .AddConfiguration(applicationConfiguration)
                                       .AddSources(configurationSources);

            if (lastProviders.Count() > 0)
            {
                configurationBuilder.AddConfiguration(new ConfigurationRoot(lastProviders));
            }

            _configuration = configurationBuilder.Build().GetSection("OrchardCore");

            _configuredTenants = _configuration.GetChildren()
                                 .Where(section => section["State"] != null)
                                 .Select(section => section.Key)
                                 .Distinct()
                                 .ToArray();

            _configBuilderFactory = (tenant) =>
            {
                var builder = new ConfigurationBuilder().AddConfiguration(_configuration);

                if (_configuredTenants.Contains(tenant))
                {
                    builder.AddConfiguration(_configuration.GetSection(tenant));
                }

                return(builder.AddSources(tenant, _tenantConfigSources));
            };
        }
        public ShellSettingsManager(
            IConfiguration applicationConfiguration,
            IShellsConfigurationSources configurationSources,
            IShellConfigurationSources tenantConfigSources,
            IShellsSettingsSources settingsSources,
            IOptions <ShellOptions> options)
        {
            _tenantConfigSources = tenantConfigSources;
            _settingsSources     = settingsSources;

            var lastProviders = (applicationConfiguration as IConfigurationRoot)?.Providers
                                .Where(p => p is EnvironmentVariablesConfigurationProvider ||
                                       p is CommandLineConfigurationProvider)
                                .ToArray();

            var configurationBuilder = new ConfigurationBuilder()
                                       .AddConfiguration(applicationConfiguration)
                                       .AddSources(configurationSources);

            if (lastProviders.Count() > 0)
            {
                configurationBuilder.AddConfiguration(new ConfigurationRoot(lastProviders));
            }

            _configuration = configurationBuilder.Build().GetSection("OrchardCore");

            _configuredTenants = _configuration.GetChildren()
                                 .Where(section => Enum.TryParse <TenantState>(section["State"], ignoreCase: true, out var result))
                                 .Select(section => section.Key)
                                 .Distinct()
                                 .ToArray();

            _configBuilderFactory = (tenant) =>
            {
                var builder = new ConfigurationBuilder().AddConfiguration(_configuration);
                builder.AddConfiguration(_configuration.GetSection(tenant));
                return(builder.AddSources(tenant, _tenantConfigSources));
            };
        }
Beispiel #5
0
 public static IConfigurationBuilder AddSources(this IConfigurationBuilder builder, IShellsSettingsSources sources)
 {
     sources.AddSources(builder);
     return(builder);
 }
Beispiel #6
0
        public static async Task <IConfigurationBuilder> AddSourcesAsync(this IConfigurationBuilder builder, IShellsSettingsSources sources)
        {
            await sources.AddSourcesAsync(builder);

            return(builder);
        }