I have a class with one List<string> variable having default values.
public class MyOptions{
public List<string> Settings {get; set;} = new List<string>(){"Controls","Menus"};
}
Then I register it in ConfigureServices method like
services.Configure<MyOptions>(Configuration.GetSection("MyOptions"));
I want to be able to change the value of Settings collection without changing the code.
In my appsettings.json, I have tried the following
{
"MyOptions":{
"Settings:0":"ReplacedSettings"
}
}
to replace "Controls" with "ReplacedSettings", but it doesn't work and I now get Settings with three values instead ["Controls","Menus","ReplacedSettings"]
whereas I want ["ReplacedSettings","Menus"].
Is this supported? Or is there any similar data structure I can with Option pattern that allows defaults values to be overridden from appsettings.json.
Thanks.