共用方式為


OptionsServiceCollectionExtensions.AddOptions 方法

定義

多載

AddOptions(IServiceCollection)

新增使用選項所需的服務。

AddOptions<TOptions>(IServiceCollection)

取得選項產生器,這個產生器會將 Configure 相同具名 TOptions 的呼叫轉送至基礎服務集合。

AddOptions<TOptions>(IServiceCollection, String)

取得選項產生器,這個產生器會將 Configure 相同具名 TOptions 的呼叫轉送至基礎服務集合。

AddOptions(IServiceCollection)

來源:
OptionsServiceCollectionExtensions.cs
來源:
OptionsServiceCollectionExtensions.cs
來源:
OptionsServiceCollectionExtensions.cs
來源:
OptionsServiceCollectionExtensions.cs
來源:
OptionsServiceCollectionExtensions.cs

新增使用選項所需的服務。

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

要新增服務的 IServiceCollection

傳回

IServiceCollection,以便鏈結其他呼叫。

適用於

AddOptions<TOptions>(IServiceCollection)

來源:
OptionsServiceCollectionExtensions.cs
來源:
OptionsServiceCollectionExtensions.cs
來源:
OptionsServiceCollectionExtensions.cs
來源:
OptionsServiceCollectionExtensions.cs
來源:
OptionsServiceCollectionExtensions.cs

取得選項產生器,這個產生器會將 Configure 相同具名 TOptions 的呼叫轉送至基礎服務集合。

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

要設定的選項類型。

參數

services
IServiceCollection

要新增服務的 IServiceCollection

傳回

可讓設定呼叫在其中鏈結的 OptionsBuilder<TOptions>

適用於

AddOptions<TOptions>(IServiceCollection, String)

來源:
OptionsServiceCollectionExtensions.cs
來源:
OptionsServiceCollectionExtensions.cs
來源:
OptionsServiceCollectionExtensions.cs
來源:
OptionsServiceCollectionExtensions.cs
來源:
OptionsServiceCollectionExtensions.cs

取得選項產生器,這個產生器會將 Configure 相同具名 TOptions 的呼叫轉送至基礎服務集合。

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

要設定的選項類型。

參數

services
IServiceCollection

要新增服務的 IServiceCollection

name
String

選項執行個體的名稱。

傳回

OptionsBuilder<TOptions> 以便 Configure 將呼叫鏈結到其中。

適用於