Example #1
0
        private static void SetupConfiguration(IConfigurationBuilder builder, IHostingEnvironment hostingEnv)
        {
            builder.Sources.Clear();
            builder.AddAppSettings(hostingEnv);

            if (hostingEnv.IsDevelopment())
            {
                builder.AddCommandLine(Environment.GetCommandLineArgs());
            }
        }
        /// <summary>
        /// Configures the builder using the default configuration sources for Gemstone projects.
        /// </summary>
        /// <param name="builder">The configuration builder.</param>
        /// <param name="configureAppSettings">Action for configuring default app settings.</param>
        /// <param name="useINI">INI file can be produced in lieu of a UI for configuration.</param>
        /// <returns>The configuration builder.</returns>
        public static IConfigurationBuilder ConfigureGemstoneDefaults(this IConfigurationBuilder builder, Action <IAppSettingsBuilder> configureAppSettings, bool useINI = false)
        {
            builder.AddAppSettings(configureAppSettings).AsReadOnly();

            if (useINI)
            {
                builder.AddGemstoneINIFile().AsReadOnly();
            }

            builder.AddSQLite();
            builder.AddEnvironmentVariables("GEMSTONE_").AsReadOnly();
            return(builder);
        }
Example #3
0
        /// <summary>
        /// Configures settings for the preferred defaults when developing applications running in a Docker container.
        /// When executing within a developer environment, the applications settings are first sourced from application
        /// setting files by calling AddAppSettings which are then overridden by any matching environment variables.
        /// When the application is not executing within the development environment, all variables are sourced from
        /// environment variables.
        /// </summary>
        /// <param name="builder">The configuration to add setting providers.</param>
        /// <param name="hostingEnv">The environment of the host.</param>
        /// <returns>Instance of the configuration builder.</returns>
        public static IConfigurationBuilder AddDockerDefaultSettings(this IConfigurationBuilder builder,
                                                                     IHostingEnvironment hostingEnv)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder), "Configuration builder not specified.");
            }

            if (hostingEnv.IsDevelopment())
            {
                builder.AddAppSettings(hostingEnv);
            }

            builder.AddEnvironmentVariables();
            return(builder);
        }
        public static IConfigurationBuilder AddAppSettings(
            this IConfigurationBuilder configurationBuilder,
            System.Configuration.Configuration configuration,
            string appSettingsKeyDelimiter,
            params string[] appSettingsSectionPrefixes)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            var appSettings = new NameValueCollection();

            foreach (KeyValueConfigurationElement appSetting in configuration.AppSettings.Settings)
            {
                appSettings.Add(appSetting.Key, appSetting.Value);
            }
            return(configurationBuilder.AddAppSettings(appSettings, appSettingsKeyDelimiter, appSettingsSectionPrefixes));
        }
Example #5
0
 private static void SetupConfiguration(HostBuilderContext context,
                                        IConfigurationBuilder builder)
 {
     builder.AddAppSettings(context.HostingEnvironment);
 }
 public static IConfigurationBuilder AddAppSettings(
     this IConfigurationBuilder configurationBuilder,
     System.Configuration.Configuration configuration,
     string appSettingsKeyDelimiter) => configurationBuilder.AddAppSettings(configuration, appSettingsKeyDelimiter, new string[] { });
 public static IConfigurationBuilder AddAppSettings(this IConfigurationBuilder configurationBuilder, System.Configuration.Configuration configuration)
 => configurationBuilder.AddAppSettings(configuration, DefaultAppSettingsKeyDelimiter);
 public static IConfigurationBuilder AddAppSettings(this IConfigurationBuilder configurationBuilder, string appSettingsKeyDelimiter, params string[] appSettingsSectionPrefixes)
 => configurationBuilder.AddAppSettings(ConfigurationManager.AppSettings, appSettingsKeyDelimiter, appSettingsSectionPrefixes);
 public static IConfigurationBuilder AddAppSettings(this IConfigurationBuilder configurationBuilder) => configurationBuilder.AddAppSettings(DefaultAppSettingsKeyDelimiter);