OptionsServiceCollectionExtensions.AddOptionsWithValidateOnStart 方法

定义

重载

AddOptionsWithValidateOnStart<TOptions,TValidateOptions>(IServiceCollection, String)

添加使用选项所需的服务,并在启动时而不是在运行时强制实施选项验证检查。

AddOptionsWithValidateOnStart<TOptions>(IServiceCollection, String)

添加使用选项所需的服务,并在启动时而不是在运行时强制实施选项验证检查。

AddOptionsWithValidateOnStart<TOptions,TValidateOptions>(IServiceCollection, String)

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

添加使用选项所需的服务,并在启动时而不是在运行时强制实施选项验证检查。

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)

类型参数

TOptions

要配置的选项类型。

TValidateOptions

IValidateOptions<TOptions> 验证程序类型。

参数

services
IServiceCollection

要向其添加服务的 IServiceCollection

name
String

选项实例的名称。

返回

IServiceCollection,以便可以链接其他调用。

注解

此方法调用 ValidateOnStart<TOptions>(OptionsBuilder<TOptions>) 扩展。

适用于

AddOptionsWithValidateOnStart<TOptions>(IServiceCollection, String)

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

添加使用选项所需的服务,并在启动时而不是在运行时强制实施选项验证检查。

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)

类型参数

TOptions

要配置的选项类型。

参数

services
IServiceCollection

要向其添加服务的 IServiceCollection

name
String

选项实例的名称。

返回

IServiceCollection,以便可以链接其他调用。

注解

此方法调用 ValidateOnStart<TOptions>(OptionsBuilder<TOptions>) 扩展。

适用于