/// <summary> /// Adds remote configuration from MyLab.ConfigServer /// </summary> public static IHostBuilder AddRemoteConfiguration(this IHostBuilder hostBuilder, bool optional = false) { hostBuilder.ConfigureAppConfiguration((ctx, cb) => { var configuration = cb.Build(); var remoteConnectionParameters = new RemoteConfigConnectionParameters(); configuration.GetSection("RemoteConfig").Bind(remoteConnectionParameters); RemoteConfigAdder.AddRemoteConfiguration(cb, remoteConnectionParameters, optional); }); return(hostBuilder); }
/// <summary> /// Inject remote configuration source into configuration system /// </summary> public static IConfigurationBuilder AddRemoteConfiguration( this IConfigurationBuilder configuration, RemoteConfigConnectionParameters connectionParameters) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (connectionParameters == null) { throw new ArgumentNullException(nameof(connectionParameters)); } var jsonProvider = new DefaultConfigJsonProvider(connectionParameters); configuration.Add(new RemoteConfigSource(jsonProvider)); return(configuration); }
public static void AddRemoteConfiguration( IConfigurationBuilder configuration, RemoteConfigConnectionParameters connectionParameters, bool optional) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (connectionParameters == null) { throw new ArgumentNullException(nameof(connectionParameters)); } var jsonProvider = new DefaultConfigJsonProvider(connectionParameters) { ThrowIfAddressNotSpecified = !optional }; configuration.Add(new RemoteConfigSource(jsonProvider)); }
public DefaultConfigJsonProvider(RemoteConfigConnectionParameters connectionParameters) { _connectionParameters = connectionParameters; }