We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create .Net plain options injection helpers that support the following:
AddTransientOptions<TOptions>()
AddScopedOptions<TOptions>()
AddSingletonOptions<TOptions>()
Conditional options injection should be supported.
Implementation example:
public static class OptionsBuilderExtensions { public static OptionsBuilder<TOptions> AddScopedOptions<TOptions>(this IServiceCollection services) where TOptions : class { services.AddScoped(serviceProvider => serviceProvider .GetService<IOptionsSnapshot<TOptions>>().Value); return services.AddOptions<TOptions>(); } }
Registration example:
services.AddScopedOptions<Options>() .Configure(o => o.MyImportantProperty = "Some important value");
That should allow injection the options directly, controlling the lifetime from the composition root instead of from the consumer, like the following:
public class Consumer { private readonly Options _options; public Consumer(Options options) { _options = options ?? throw new ArgumentNullException(nameof(options)); } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Create .Net plain options injection helpers that support the following:
AddTransientOptions<TOptions>()
AddScopedOptions<TOptions>()
AddSingletonOptions<TOptions>()
Conditional options injection should be supported.
Implementation example:
Registration example:
That should allow injection the options directly, controlling the lifetime from the composition root instead of from the consumer, like the following:
The text was updated successfully, but these errors were encountered: