Extending - Loaders
It's very easy to add custom providers.
It's very easy to add custom providers. Remember that .NET creates a ConfigurationSource that implements and returns a ConfigurationProvider.
You can see this pattern here: Implement a custom configuration provider.
Custom Implementation
To implement a custom source and provider only requires a single line of code.
Call the ConfigureConfiguration method.
This callback sends you two parameters:
IConfigurationBuilder This builder allows you to add a custom source.
EnivronmentString the string variable that is the current environment.
Simply add a new instance of the source. (See line 5)
You can see how easy it is in the future to reload the providers. You can reload all of them or specific types by supplying that type information.
Using the built in SQL Provider
If you're trying to load values from MSSQL then Perigee ships with a loader ready to go in only a single line of code. Simply call the configuration method and supply the connection string, query, and prefix.
Last updated