OptionsServiceCollectionExtensions.AddOptionsWithValidateOnStart Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
AddOptionsWithValidateOnStart<TOptions,TValidateOptions>(IServiceCollection, String) |
Adds services required for using options and enforces options validation check on start rather than at run time. |
AddOptionsWithValidateOnStart<TOptions>(IServiceCollection, String) |
Adds services required for using options and enforces options validation check on start rather than at run time. |
Adds services required for using options and enforces options validation check on start rather than at run time.
public static Microsoft.Extensions.Options.OptionsBuilder<TOptions> AddOptionsWithValidateOnStart<TOptions,TValidateOptions>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, string? name = default) where TOptions : class where TValidateOptions : class, Microsoft.Extensions.Options.IValidateOptions<TOptions>;
static member AddOptionsWithValidateOnStart : Microsoft.Extensions.DependencyInjection.IServiceCollection * string -> Microsoft.Extensions.Options.OptionsBuilder<'Options (requires 'Options : null)> (requires 'Options : null and 'ValidateOptions : null and 'ValidateOptions :> Microsoft.Extensions.Options.IValidateOptions<'Options>)
<Extension()>
Public Function AddOptionsWithValidateOnStart(Of TOptions As Class, TValidateOptions As Class) (services As IServiceCollection, Optional name As String = Nothing) As OptionsBuilder(Of TOptions)
Type Parameters
- TOptions
The options type to be configured.
- TValidateOptions
The IValidateOptions<TOptions> validator type.
Parameters
- services
- IServiceCollection
The IServiceCollection to add the services to.
- name
- String
The name of the options instance.
Returns
The OptionsBuilder<TOptions> so that configure calls can be chained in it.
Remarks
The ValidateOnStart<TOptions>(OptionsBuilder<TOptions>) extension is called by this method.
Applies to
.NET 9 (package-provided) and other versions
Product | Versions |
---|---|
.NET | 8 (package-provided), 9 (package-provided) |
.NET Framework | 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided) |
.NET Standard | 2.0 (package-provided), 2.1 (package-provided) |
Adds services required for using options and enforces options validation check on start rather than at run time.
public static Microsoft.Extensions.Options.OptionsBuilder<TOptions> AddOptionsWithValidateOnStart<TOptions>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, string? name = default) where TOptions : class;
static member AddOptionsWithValidateOnStart : Microsoft.Extensions.DependencyInjection.IServiceCollection * string -> Microsoft.Extensions.Options.OptionsBuilder<'Options (requires 'Options : null)> (requires 'Options : null)
<Extension()>
Public Function AddOptionsWithValidateOnStart(Of TOptions As Class) (services As IServiceCollection, Optional name As String = Nothing) As OptionsBuilder(Of TOptions)
Type Parameters
- TOptions
The options type to be configured.
Parameters
- services
- IServiceCollection
The IServiceCollection to add the services to.
- name
- String
The name of the options instance.
Returns
The OptionsBuilder<TOptions> so that configure calls can be chained in it.
Remarks
The ValidateOnStart<TOptions>(OptionsBuilder<TOptions>) extension is called by this method.
Applies to
.NET 9 (package-provided) and other versions
Product | Versions |
---|---|
.NET | 8 (package-provided), 9 (package-provided) |
.NET Framework | 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided) |
.NET Standard | 2.0 (package-provided), 2.1 (package-provided) |
.NET feedback
.NET is an open source project. Select a link to provide feedback: