Поділитися через


OptionsBuilderConfigurationExtensions.BindConfiguration<TOptions> Method

Definition

Registers the dependency injection container to bind TOptions against the IConfiguration obtained from the DI service provider.

public static Microsoft.Extensions.Options.OptionsBuilder<TOptions> BindConfiguration<TOptions> (this Microsoft.Extensions.Options.OptionsBuilder<TOptions> optionsBuilder, string configSectionPath, Action<Microsoft.Extensions.Configuration.BinderOptions>? configureBinder = default) where TOptions : class;
static member BindConfiguration : Microsoft.Extensions.Options.OptionsBuilder<'Options (requires 'Options : null)> * string * Action<Microsoft.Extensions.Configuration.BinderOptions> -> Microsoft.Extensions.Options.OptionsBuilder<'Options (requires 'Options : null)> (requires 'Options : null)
<Extension()>
Public Function BindConfiguration(Of TOptions As Class) (optionsBuilder As OptionsBuilder(Of TOptions), configSectionPath As String, Optional configureBinder As Action(Of BinderOptions) = Nothing) As OptionsBuilder(Of TOptions)

Type Parameters

TOptions

The options type to be configured.

Parameters

optionsBuilder
OptionsBuilder<TOptions>

The options builder to add the services to.

configSectionPath
String

The name of the configuration section to bind from.

configureBinder
Action<BinderOptions>

Optional. Used to configure the BinderOptions.

Returns

The OptionsBuilder<TOptions> so that additional calls can be chained.

Exceptions

optionsBuilder or configSectionPath is null.

Applies to

See also