OptionsServiceCollectionExtensions.AddOptions 方法

定義

多載

AddOptions(IServiceCollection)

新增使用選項所需的服務。Adds services required for using options.

AddOptions<TOptions>(IServiceCollection)

取得選項產生器,將同樣名為 TOptionsConfigure 呼叫轉寄至基礎服務集合。Gets an options builder that forwards Configure calls for the same named TOptions to the underlying service collection.

AddOptions<TOptions>(IServiceCollection, String)

取得選項產生器,將同樣名為 TOptionsConfigure 呼叫轉寄至基礎服務集合。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)

取得選項產生器,將同樣名為 TOptionsConfigure 呼叫轉寄至基礎服務集合。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)

取得選項產生器,將同樣名為 TOptionsConfigure 呼叫轉寄至基礎服務集合。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> 可讓 Configure呼叫在其中進行鏈結。The OptionsBuilder<TOptions> so that Configure calls can be chained in it.

適用於