Skip to content

Instantly share code, notes, and snippets.

@lawrence-laz
Created September 28, 2020 12:54
Show Gist options
  • Save lawrence-laz/2f7b1cf511f835693eec2995cccfad8c to your computer and use it in GitHub Desktop.
Save lawrence-laz/2f7b1cf511f835693eec2995cccfad8c to your computer and use it in GitHub Desktop.
Configure Options
// 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