OptionsServiceCollectionExtensions.AddOptions 方法

定义

重载

AddOptions(IServiceCollection)

添加使用选项所需的服务。Adds services required for using options.

AddOptions<TOptions>(IServiceCollection)

获取一个选项生成器,以便将同一命名 TOptions配置调用转发到基础服务集合。Gets an options builder that forwards Configure calls for the same named TOptions to the underlying service collection.

AddOptions<TOptions>(IServiceCollection, String)

获取一个选项生成器,以便将同一命名 TOptions配置调用转发到基础服务集合。Gets an options builder that forwards Configure calls for the same named TOptions to the underlying service collection.

AddOptions(IServiceCollection)

添加使用选项所需的服务。Adds services required for using options.

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddOptions(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddOptions (this Microsoft.Extensions.DependencyInjection.IServiceCollection services);
static member AddOptions : Microsoft.Extensions.DependencyInjection.IServiceCollection -> Microsoft.Extensions.DependencyInjection.IServiceCollection
<Extension()>
Public Function AddOptions (services As IServiceCollection) As IServiceCollection

参数

services
IServiceCollection

要向其中添加服务的 IServiceCollectionThe IServiceCollection to add the services to.

返回

IServiceCollection

IServiceCollection,以便可以链接其他调用。The IServiceCollection so that additional calls can be chained.

适用于

AddOptions<TOptions>(IServiceCollection)

获取一个选项生成器,以便将同一命名 TOptions配置调用转发到基础服务集合。Gets an options builder that forwards Configure calls for the same named TOptions to the underlying service collection.

public:
generic <typename TOptions>
 where TOptions : class[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::Options::OptionsBuilder<TOptions> ^ AddOptions(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services);
public static Microsoft.Extensions.Options.OptionsBuilder<TOptions> AddOptions<TOptions> (this Microsoft.Extensions.DependencyInjection.IServiceCollection services) where TOptions : class;
static member AddOptions : Microsoft.Extensions.DependencyInjection.IServiceCollection -> Microsoft.Extensions.Options.OptionsBuilder<'Options (requires 'Options : null)> (requires 'Options : null)
<Extension()>
Public Function AddOptions(Of TOptions As Class) (services As IServiceCollection) As OptionsBuilder(Of TOptions)

类型参数

TOptions

要配置的选项类型。The options type to be configured.

参数

services
IServiceCollection

要向其中添加服务的 IServiceCollectionThe IServiceCollection to add the services to.

返回

OptionsBuilder<TOptions>

OptionsBuilder<TOptions>,以便可以在其中链接配置调用。The OptionsBuilder<TOptions> so that configure calls can be chained in it.

适用于

AddOptions<TOptions>(IServiceCollection, String)

获取一个选项生成器,以便将同一命名 TOptions配置调用转发到基础服务集合。Gets an options builder that forwards Configure calls for the same named TOptions to the underlying service collection.

public:
generic <typename TOptions>
 where TOptions : class[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::Options::OptionsBuilder<TOptions> ^ AddOptions(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, System::String ^ name);
public static Microsoft.Extensions.Options.OptionsBuilder<TOptions> AddOptions<TOptions> (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, string name) where TOptions : class;
static member AddOptions : Microsoft.Extensions.DependencyInjection.IServiceCollection * string -> Microsoft.Extensions.Options.OptionsBuilder<'Options (requires 'Options : null)> (requires 'Options : null)
<Extension()>
Public Function AddOptions(Of TOptions As Class) (services As IServiceCollection, name As String) As OptionsBuilder(Of TOptions)

类型参数

TOptions

要配置的选项类型。The options type to be configured.

参数

services
IServiceCollection

要向其中添加服务的 IServiceCollectionThe IServiceCollection to add the services to.

name
String

选项实例的名称。The name of the options instance.

返回

OptionsBuilder<TOptions>

OptionsBuilder<TOptions>,以便可在其中链接配置调用。The OptionsBuilder<TOptions> so that Configure calls can be chained in it.

适用于