public static IConfigurationBuilder AddConfigServer(this IConfigurationBuilder configurationBuilder, string environment, string applicationName, ILoggerFactory logFactory = null) { if (configurationBuilder == null) { throw new ArgumentNullException(nameof(configurationBuilder)); } var settings = new ConfigServerClientSettings() { Name = applicationName ?? Assembly.GetEntryAssembly()?.GetName().Name, Environment = environment ?? ConfigServerClientSettings.DEFAULT_ENVIRONMENT }; return(configurationBuilder.AddConfigServer(settings, logFactory)); }
/// <summary> /// Initializes a new instance of the <see cref="ConfigServerConfigurationSource"/> class. /// </summary> /// <param name="defaultSettings">the default settings used by the Config Server client</param> /// <param name="sources">configuration sources used by the Config Server client. The <see cref="Configuration"/> will be built from these sources and the /// values will override those found in <see cref="DefaultSettings"/></param> /// <param name="properties">properties to be used when sources are built</param> /// <param name="logFactory">optional logger factory used by the client</param> public ConfigServerConfigurationSource(ConfigServerClientSettings defaultSettings, IList <IConfigurationSource> sources, IDictionary <string, object> properties = null, ILoggerFactory logFactory = null) { if (sources == null) { throw new ArgumentNullException(nameof(sources)); } _sources = new List <IConfigurationSource>(sources); if (properties != null) { _properties = new Dictionary <string, object>(properties); } DefaultSettings = defaultSettings ?? throw new ArgumentNullException(nameof(defaultSettings)); LogFactory = logFactory; }
/// <summary> /// Initializes a new instance of the <see cref="ConfigServerConfigurationSource"/> class. /// </summary> /// <param name="defaultSettings">the default settings used by the Config Server client</param> /// <param name="configuration">configuration used by the Config Server client. Values will override those found in default settings</param> /// <param name="logFactory">optional logger factory used by the client</param> public ConfigServerConfigurationSource(ConfigServerClientSettings defaultSettings, IConfiguration configuration, ILoggerFactory logFactory = null) { Configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); DefaultSettings = defaultSettings ?? throw new ArgumentNullException(nameof(defaultSettings)); LogFactory = logFactory; }
public static IConfigurationBuilder AddConfigServer(this IConfigurationBuilder configurationBuilder, ConfigServerClientSettings defaultSettings, ILoggerFactory logFactory = null) { if (configurationBuilder == null) { throw new ArgumentNullException(nameof(configurationBuilder)); } if (defaultSettings == null) { throw new ArgumentNullException(nameof(defaultSettings)); } //if (!configurationBuilder.Sources.Any(c => c.GetType() == typeof(CloudFoundryConfigurationSource))) //{ // configurationBuilder.Add(new CloudFoundryConfigurationSource()); //} configurationBuilder.Add(new ConfigServerConfigurationSource(defaultSettings, configurationBuilder.Sources, configurationBuilder.Properties, logFactory)); return(configurationBuilder); }