Last active
February 10, 2023 14:27
-
-
Save AndyButland/d04ff33f5efa3b78ed9aeaaf9b5253a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IConfigurationSection mySettingsSection = builder.Configuration.GetSection("MySettings"); | |
builder.Services.Configure<MySettings>(mySettingsSection); | |
services.PostConfigure<MySettings>(options => | |
{ | |
if(!options.MyOptions.Any(x => x.Alias == "itemOne")) | |
{ | |
options.MyOptions.Add(new MyOption { Alias = "itemOne", Value = 0 }); | |
} | |
if(!options.MyOptions.Any(x => x.Alias == "itemTwo")) | |
{ | |
options.MyOptions.Add(new MyOption { Alias = "itemTwo", Value = 0 }); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment