Skip to content
ConfigureAll is a library to make using the Options configuration pattern easier.
C#
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src/SapientGuardian.ConfigureAll
test/ConfigureAllTests
.gitattributes
.gitignore
.travis.yml
LICENSE
README.md
SapientGuardian.ConfigureAll.sln
appveyor.yml
global.json

README.md

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.
You can’t perform that action at this time.