Прочетете на английски

Споделяне чрез


OptionsServiceCollectionExtensions.AddOptions Method

Definition

Overloads

AddOptions(IServiceCollection)

Adds services required for using options.

AddOptions<TOptions>(IServiceCollection)

Gets an options builder that forwards Configure calls for the same TOptions to the underlying service collection.

AddOptions<TOptions>(IServiceCollection, String)

Gets an options builder that forwards Configure calls for the same named TOptions to the underlying service collection.

AddOptions(IServiceCollection)

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

Adds services required for using options.

C#
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddOptions(this Microsoft.Extensions.DependencyInjection.IServiceCollection services);

Parameters

services
IServiceCollection

The IServiceCollection to add the services to.

Returns

The IServiceCollection so that additional calls can be chained.

Applies to

.NET 10 (package-provided) и други версии
Продукт Версии
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Standard 2.0 (package-provided), 2.1 (package-provided)

AddOptions<TOptions>(IServiceCollection)

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

Gets an options builder that forwards Configure calls for the same TOptions to the underlying service collection.

C#
public static Microsoft.Extensions.Options.OptionsBuilder<TOptions> AddOptions<TOptions>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services) where TOptions : class;

Type Parameters

TOptions

The options type to be configured.

Parameters

services
IServiceCollection

The IServiceCollection to add the services to.

Returns

The OptionsBuilder<TOptions> so that configure calls can be chained in it.

Applies to

.NET 10 (package-provided) и други версии
Продукт Версии
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Standard 2.0 (package-provided), 2.1 (package-provided)

AddOptions<TOptions>(IServiceCollection, String)

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

Gets an options builder that forwards Configure calls for the same named TOptions to the underlying service collection.

C#
public static Microsoft.Extensions.Options.OptionsBuilder<TOptions> AddOptions<TOptions>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, string? name) 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.

Applies to

.NET 10 (package-provided) и други версии
Продукт Версии
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Standard 2.0 (package-provided), 2.1 (package-provided)