I have a .NET Core console application setup with all the packages to use the Options pattern. Settings coming from my appsettings.json
work just fine, but my environment variables contain period characters like:
App.Setting.Value1 = "someval"
App.Setting.Val2 = "somethingelse"
I am trying to strongly type my settings using the Options pattern, but C# property names can't have period characters in them.
How do I configure during DI init time for this?
use custom attribute binder:
public class MySetting{
[ConfigurationKeyName(Name="App.Settings.Value1")]
public string Value1{get;set;}
[ConfigurationKeyName(Name="App.Settings.Value2")]
public string Value2{get;set;}
}
source: https://github.com/dotnet/runtime/issues/36010
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With