ConfigurationBinder.Get 方法

定义

重载

Get(IConfiguration, Type)

尝试将配置实例绑定到类型为 T 的新实例。如果此配置节包含一个值,则将使用该值。Attempts to bind the configuration instance to a new instance of type T. If this configuration section has a value, that will be used. 否则,通过按递归方式根据配置键匹配属性名称来进行绑定。Otherwise binding by matching property names against configuration keys recursively.

Get(IConfiguration, Type, Action<BinderOptions>)

尝试将配置实例绑定到类型为 T 的新实例。如果此配置节包含一个值,则将使用该值。Attempts to bind the configuration instance to a new instance of type T. If this configuration section has a value, that will be used. 否则,通过按递归方式根据配置键匹配属性名称来进行绑定。Otherwise binding by matching property names against configuration keys recursively.

Get<T>(IConfiguration)

尝试将配置实例绑定到类型为 T 的新实例。如果此配置节包含一个值,则将使用该值。Attempts to bind the configuration instance to a new instance of type T. If this configuration section has a value, that will be used. 否则,通过按递归方式根据配置键匹配属性名称来进行绑定。Otherwise binding by matching property names against configuration keys recursively.

Get<T>(IConfiguration, Action<BinderOptions>)

尝试将配置实例绑定到类型为 T 的新实例。如果此配置节包含一个值,则将使用该值。Attempts to bind the configuration instance to a new instance of type T. If this configuration section has a value, that will be used. 否则,通过按递归方式根据配置键匹配属性名称来进行绑定。Otherwise binding by matching property names against configuration keys recursively.

Get(IConfiguration, Type)

尝试将配置实例绑定到类型为 T 的新实例。如果此配置节包含一个值,则将使用该值。Attempts to bind the configuration instance to a new instance of type T. If this configuration section has a value, that will be used. 否则,通过按递归方式根据配置键匹配属性名称来进行绑定。Otherwise binding by matching property names against configuration keys recursively.

public:
[System::Runtime::CompilerServices::Extension]
 static System::Object ^ Get(Microsoft::Extensions::Configuration::IConfiguration ^ configuration, Type ^ type);
public static object Get (this Microsoft.Extensions.Configuration.IConfiguration configuration, Type type);
static member Get : Microsoft.Extensions.Configuration.IConfiguration * Type -> obj
<Extension()>
Public Function Get (configuration As IConfiguration, type As Type) As Object

参数

configuration
IConfiguration

要绑定的配置实例。The configuration instance to bind.

type
Type

要绑定的新实例的类型。The type of the new instance to bind.

返回

Object

如果成功,则为新的实例;否则为 null。The new instance if successful, null otherwise.

适用于

Get(IConfiguration, Type, Action<BinderOptions>)

尝试将配置实例绑定到类型为 T 的新实例。如果此配置节包含一个值,则将使用该值。Attempts to bind the configuration instance to a new instance of type T. If this configuration section has a value, that will be used. 否则,通过按递归方式根据配置键匹配属性名称来进行绑定。Otherwise binding by matching property names against configuration keys recursively.

public:
[System::Runtime::CompilerServices::Extension]
 static System::Object ^ Get(Microsoft::Extensions::Configuration::IConfiguration ^ configuration, Type ^ type, Action<Microsoft::Extensions::Configuration::BinderOptions ^> ^ configureOptions);
public static object Get (this Microsoft.Extensions.Configuration.IConfiguration configuration, Type type, Action<Microsoft.Extensions.Configuration.BinderOptions> configureOptions);
static member Get : Microsoft.Extensions.Configuration.IConfiguration * Type * Action<Microsoft.Extensions.Configuration.BinderOptions> -> obj
<Extension()>
Public Function Get (configuration As IConfiguration, type As Type, configureOptions As Action(Of BinderOptions)) As Object

参数

configuration
IConfiguration

要绑定的配置实例。The configuration instance to bind.

type
Type

要绑定的新实例的类型。The type of the new instance to bind.

configureOptions
Action<BinderOptions>

配置绑定器选项。Configures the binder options.

返回

Object

如果成功,则为新的实例;否则为 null。The new instance if successful, null otherwise.

适用于

Get<T>(IConfiguration)

尝试将配置实例绑定到类型为 T 的新实例。如果此配置节包含一个值,则将使用该值。Attempts to bind the configuration instance to a new instance of type T. If this configuration section has a value, that will be used. 否则,通过按递归方式根据配置键匹配属性名称来进行绑定。Otherwise binding by matching property names against configuration keys recursively.

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static T Get(Microsoft::Extensions::Configuration::IConfiguration ^ configuration);
public static T Get<T> (this Microsoft.Extensions.Configuration.IConfiguration configuration);
static member Get : Microsoft.Extensions.Configuration.IConfiguration -> 'T
<Extension()>
Public Function Get(Of T) (configuration As IConfiguration) As T

类型参数

T

要绑定的新实例的类型。The type of the new instance to bind.

参数

configuration
IConfiguration

要绑定的配置实例。The configuration instance to bind.

返回

T

如果成功,则为新的 T 实例;否则为默认值 (T)。The new instance of T if successful, default(T) otherwise.

适用于

Get<T>(IConfiguration, Action<BinderOptions>)

尝试将配置实例绑定到类型为 T 的新实例。如果此配置节包含一个值,则将使用该值。Attempts to bind the configuration instance to a new instance of type T. If this configuration section has a value, that will be used. 否则,通过按递归方式根据配置键匹配属性名称来进行绑定。Otherwise binding by matching property names against configuration keys recursively.

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static T Get(Microsoft::Extensions::Configuration::IConfiguration ^ configuration, Action<Microsoft::Extensions::Configuration::BinderOptions ^> ^ configureOptions);
public static T Get<T> (this Microsoft.Extensions.Configuration.IConfiguration configuration, Action<Microsoft.Extensions.Configuration.BinderOptions> configureOptions);
static member Get : Microsoft.Extensions.Configuration.IConfiguration * Action<Microsoft.Extensions.Configuration.BinderOptions> -> 'T
<Extension()>
Public Function Get(Of T) (configuration As IConfiguration, configureOptions As Action(Of BinderOptions)) As T

类型参数

T

要绑定的新实例的类型。The type of the new instance to bind.

参数

configuration
IConfiguration

要绑定的配置实例。The configuration instance to bind.

configureOptions
Action<BinderOptions>

配置绑定器选项。Configures the binder options.

返回

T

如果成功,则为新的 T 实例;否则为默认值 (T)。The new instance of T if successful, default(T) otherwise.

适用于