public static IServiceCollection AddFromConfig <TConfigClass>(
            this IServiceCollection serviceCollection,
            IConfiguration configuration,
            params BindOptions[] options)
            where TConfigClass : class
        {
            Check.NotNull(configuration, nameof(configuration));
            var create = ConfigFactoryMethods.BuildFactory <TConfigClass>(configuration,
                                                                          BindOptions.IsDontThrowIfSectionIsMissingOrEmptySet(options));

            return(serviceCollection.AddSingleton(create()));
        }
예제 #2
0
 public static IServiceCollection AddBoundToConfig <TConfigClass>(
     this IServiceCollection serviceCollection,
     IConfiguration configuration,
     Action <Exception, Type> whenConfigurationChangeCausesError = null,
     params BindOptions[] options)
     where TConfigClass : class =>
 serviceCollection.AddBoundToConfig <TConfigClass>(
     configuration,
     new BindPolicy
 {
     ThrowIfSectionIsMissingOrEmpty     = BindOptions.IsDontThrowIfSectionIsMissingOrEmptySet(options),
     WhenConfigurationChangeCausesError = whenConfigurationChangeCausesError
 });