Skip to content

ConfigureAll is a library to make using the Options configuration pattern easier.

License

Notifications You must be signed in to change notification settings

SapientGuardian/SapientGuardian.ConfigureAll

Repository files navigation

SapientGuardian.ConfigureAll

Windows Build status
Linux/OSX Build Status
NuGet Package

Description

ConfigureAll is a library to make using the Options configuration pattern easier. Just add the ConfigurationObject attribute and ConfigureAll!

How to use it

  1. Add the ConfigurationObject attribute on your configuration objects indicating the name of the key in your configuration that maps to the object
    using SapientGuardian.ConfigureAll;
    
    
    namespace ConfigureAllTests
    {
        [ConfigurationObject("TestKey")]
        public class TestConfigurationObject
        {    
            public string TestValue { get; set; }
        }
    }
  2. Call ConfigureAll in your ConfigureServices method
    using Microsoft.Extensions.Options;
    
    public IConfiguration Configuration { get; }
    
    public void ConfigureServices(IServiceCollection services)
        {            
            services.AddOptions();
    
            services.ConfigureAll(this.GetType().GetTypeInfo().Assembly, Configuration);
        }
    If your configuration objects are stored in a different assembly than the one containing your ConfigureServices method, be sure to specify that in the first parameter to ConfigureAll.

About

ConfigureAll is a library to make using the Options configuration pattern easier.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages