public static ConfigurationServiceBuilder AddXml <TSettings>(this ConfigurationServiceBuilder builder, string path, Action <IServiceProvider, SettingsProviderOptions> configure) where TSettings : class, new() => AddProvider(builder, serviceProvider => { var settingsProviderOptions = new SettingsProviderOptions(); configure?.Invoke(serviceProvider, settingsProviderOptions); var provider = new XmlSettingsProvider <TSettings>(settingsProviderOptions, path); return(provider); });
public static ConfigurationServiceBuilder AddConfiguration(this IServiceCollection services) { if (services == null) { throw new ArgumentNullException(nameof(services)); } var builder = new ConfigurationServiceBuilder(services); services.TryAddSingleton(typeof(IConfiguration <>), typeof(Configuration <>)); services.TryAddSingleton(typeof(IConfigurator <>), typeof(Configurator <>)); return(builder); }
public static ConfigurationServiceBuilder AddProvider <TSettings>(this ConfigurationServiceBuilder builder, Func <IServiceProvider, SettingsProvider <TSettings> > providerFactory) where TSettings : class, new() { if (providerFactory == null) { throw new ArgumentNullException(nameof(providerFactory)); } builder.Services.TryAddSingleton(serviceProvider => { var configurationOptions = new ConfigurationOptions <TSettings>(providerFactory(serviceProvider)); return(configurationOptions); }); return(builder); }
public static ConfigurationServiceBuilder AddProvider <TSettings>(this ConfigurationServiceBuilder builder, SettingsProvider <TSettings> provider) where TSettings : class, new() => AddProvider(builder, _ => provider);
public static ConfigurationServiceBuilder AddXml <TSettings>(this ConfigurationServiceBuilder builder, string path, Action <SettingsProviderOptions> configure = null) where TSettings : class, new() => AddXml <TSettings>(builder, path, (_, options) => configure?.Invoke(options));