This project aims to extend basic configuration methods for ASP.NET Core Currently, only MongoDb is added as configuratin provider As for now, I consider to be added: Telegram (via BOT)
To install via dotnet CLI:
dotnet add package FireConfig
Via Package Manager:
Install-Package FireConfig
In MongoDb, you need to structure records like this:
{
"_id": "...",
"ProjectCommon": {
"ConnectionStrings": {
"MongoDb": "<Your connection Id string>",
"NpgSql": "<Your connection Id string>"
},
"TokenOptions": {
"SigningKey": "<Your very very secret key>"
},
"SomeTestOptions": [
{
"Test1": 1
}, {
"Test2": 2
}, "Test3"]
}
}
ProjectCommon is a "Key" here, you could specify your keys in options (more information below) All the keys are trimmed after readingm, they are used to limit records which your app will read from DB Something similar you could see while using Azure AppConfiguration
// initialize options
var mongoConfigOptions = configuration
.GetSection(MongoConfigConnectionOptions.MongoConfigConnectionOptionsName)
.Get<MongoConfigConnectionOptions>();
// add new configuration to ConfigureHostBuilder
builder.ConfigureAppConfiguration(configBuilder =>
{
configBuilder.AddMongoDbConfiguration(mongoConfigOptions);
});
Typical options loks like:
"MongoConfigConnectionOptions": {
"ConnectionString": "mongodb://localhost:27017",
"DatabaseName": "configdb",
"CollectionName": "configuration",
"Keys": [
"ProjectCommon"
]
}