Open ttustonic opened 3 months ago
cc @nickrandolph, @dr1rrb, @eriklimakc
Hi @ttustonic!
It seems that IOptions
In order to access the options for a specific name you would need to inject an IOptionsSnapshot<AppTest> myConfig
instead of an IOptions in the constructor and retrieve the named section by calling myConfig.Get("AppTestTEST")
Let me know if that works for you!
Current behavior
Setting
configurationSection
parameter doesn't work, configuration is not read from config file when the config section doesn't match the class name SettingconfigSection
worksExpected behavior
Both
configurationSection
andconfigSection
should work the same.How to reproduce it (as minimally and precisely as possible)
Attached is a new project from the wizard. In the project there's a new config class,
AppTest
.public record AppTest { public string? InfoTitle { get; init; } }
In the config file there's a section
"AppTestTEST": { "InfoTitle": "AppInfo title" }
in UseConfiguration there's a line:.Section<AppTest>(configurationSection: "AppTestTEST")
which doesn't work (value of InfoTitle is null), but.Section<AppTest>(configSection: (hbc) => hbc.Configuration.GetSection("AppTestTEST"))
works as expected.MainViewModel
has an additional parameter,IOptions<AppTest> appTest
, and new propertyTestTitle
which is bound to the Textbox in theMainPage.xaml
Environment
Nuget Package (s): default packages from the Uno Platform App wizard Package Version(s):
Affected platform(s):
Visual Studio:
Relevant plugins:
Anything else we need to know?
UnoApp1.zip