OptionsServiceCollectionExtensions.AddOptionsWithValidateOnStart Method

Definition

Overloads

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.

AddOptionsWithValidateOnStart<TOptions,TValidateOptions>(IServiceCollection, String)

Source:
OptionsServiceCollectionExtensions.cs
Source:
OptionsServiceCollectionExtensions.cs
Source:
OptionsServiceCollectionExtensions.cs

Adds services required for using options and enforces options validation check on start rather than at run time.

C#
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>;

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)

AddOptionsWithValidateOnStart<TOptions>(IServiceCollection, String)

Source:
OptionsServiceCollectionExtensions.cs
Source:
OptionsServiceCollectionExtensions.cs
Source:
OptionsServiceCollectionExtensions.cs

Adds services required for using options and enforces options validation check on start rather than at run time.

C#
public static Microsoft.Extensions.Options.OptionsBuilder<TOptions> AddOptionsWithValidateOnStart<TOptions>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, string? name = default) where TOptions : class;

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)