Extending - Loaders
It's very easy to add custom providers.
Last updated
It's very easy to add custom providers.
Last updated
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: .
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.
If you're trying to load values from a SQL database, 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, query, and prefix.
Because this works with IDBConnection
, it works with MSSQL, PostGres, MySql... etc. Just supply the appropriate connection and it will work!