Flash.Configuration is a configuration management tool that enables dynamic parsing and updating of configuration settings, including updating configuration files after build.
$ dotnet add package Flash.ConfigurationFlash.Configuration is a configuration management tool that enables dynamic parsing and updating of configuration settings, including updating configuration files after build.
To add the latest NuGet package:
Install-Package Flash.Configuration --version 8.0.0
or
dotnet add package Flash.Configuration --version 8.0.0
The package can work with the following project types:
Create a class for configuration
Sample
[FlashOrder(4)]
[FlashConfig("ConnectionStrings", environment: "Development")]
[FlashConfig("ConnectionStrings", environment: "Staging")]
public class ConnectionStrings
{
[FlashProperty("DefaultConnection")]
[FlashValue("Server=dev.localhost;Database=dev_db;User Id=dev_user;Password=******;", environment: "Development")]
[FlashValue("Server=staging.localhost;Database=staging_db;User Id=staging_user;Password=******;",
environment: "Staging")]
public string DefaultConnection { get; } = string.Empty;
[FlashIgnore]
[FlashProperty("Enabled")]
[FlashValue(false, environment: "Development")]
[FlashValue(true, environment: "Staging")]
public bool Enabled { get; }
}
appsettings.Development.jsonappsettings.Staging.jsonappsettings.Development.json{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"ConnectionStrings": {
"DefaultConnection": "Server=dev.localhost;Database=dev_db;User Id=dev_user;Password=******;"
}
}
appsettings.Staging.json{
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
},
"ConnectionStrings": {
"DefaultConnection": "Server=staging.localhost;Database=staging_db;User Id=staging_user;Password=******;"
}
}
⚠️ Warning The advanced complex sample is available with the link with all classes and configuration files.