An extension to enable configuration variable expansion. It depends on Microsoft.Extensions.Configuration and Microsoft.Extensions.Configuration.Binder.
In any declaration you can use a variable expansion like ${ <VARIABLE_NAME> }
. The <VARIABLE_NAME>
will be expandaded (replaced) by any value which key is defined in the Configuration
object. A fallback value can be provided for the abscense of a variable/configuration ${ <VARIABLE_NAME> ?? <DEFAULT_VALUE> }
{
"db": {
"host": "${ DB_HOST ?? localhost }"
}
}
configuration.ResolveValue<String>("db:host")