.NET Configuration
The configuration system depends on configuration providers - the sources of configuration data.
Options
The IOptions<T>
instance is registered as a singleton.
The class/record for our options needs to have properties that:
- are public
- have getters
- have setters (or non-null value if complex type)
- are not indexers
Lambda
We are able to customize Options in runtime:
The configuration system executes both operations. First, the IConfiguration
is read and then Mode
property is overwritten.
Without Options
Nuget packages:
- Microsoft.Extensions.Configuration;
- Microsoft.Extensions.Configuration.Files.Json
- Microsoft.Extensions.Configuration.Binder