Created
September 28, 2020 12:54
-
-
Save lawrence-laz/2f7b1cf511f835693eec2995cccfad8c to your computer and use it in GitHub Desktop.
Configure Options
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
// Configure all named options without dependencies. | |
services.ConfigureAll<TOptions>(options => | |
{ | |
// Set your options here. | |
}); | |
// Configure all named options with dependencies. | |
// Setting name to null is a key here. | |
services.AddSingleton<IConfigureOptions<TOptions>>(provider => | |
{ | |
return new ConfigureNamedOptions<TOptions>(name: null, options => | |
{ | |
// Set your options here using provider. | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment