pereirazc / Configuration.Expander

An extension to enable variable expansion in .NET config files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Configuration.Expander Extension

Nuget

An extension to enable configuration variable expansion. It depends on Microsoft.Extensions.Configuration and Microsoft.Extensions.Configuration.Binder.

Usage

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> }

Declaration

{
    "db": {
        "host": "${ DB_HOST ?? localhost }"
    }
}

Usage in code

configuration.ResolveValue<String>("db:host")

About

An extension to enable variable expansion in .NET config files

License:MIT License


Languages

Language:C# 95.9%Language:Shell 4.1%