ConfigurationBinder.Get 方法

定义

重载

名称 说明
Get(IConfiguration, Type)

尝试将配置实例绑定到 T 类型的新实例。如果此配置节具有一个值,将使用该值。 否则,通过以递归方式将属性名称与配置键匹配来绑定。

Get(IConfiguration, Type, Action<BinderOptions>)

尝试将配置实例绑定到 T 类型的新实例。如果此配置节具有一个值,将使用该值。 否则,通过以递归方式将属性名称与配置键匹配来绑定。

Get<T>(IConfiguration)

尝试将配置实例绑定到 T 类型的新实例。如果此配置节具有一个值,将使用该值。 否则,通过以递归方式将属性名称与配置键匹配来绑定。

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

尝试将配置实例绑定到 T 类型的新实例。如果此配置节具有一个值,将使用该值。 否则,通过以递归方式将属性名称与配置键匹配来绑定。

Get(IConfiguration, Type)

Source:
ConfigurationBinder.cs
Source:
ConfigurationBinder.cs
Source:
ConfigurationBinder.cs
Source:
ConfigurationBinder.cs

尝试将配置实例绑定到 T 类型的新实例。如果此配置节具有一个值,将使用该值。 否则,通过以递归方式将属性名称与配置键匹配来绑定。

public:
[System::Runtime::CompilerServices::Extension]
 static System::Object ^ Get(Microsoft::Extensions::Configuration::IConfiguration ^ configuration, Type ^ type);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Binding strongly typed objects to configuration values requires generating dynamic code at runtime, for example instantiating generic types.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("In case the type is non-primitive, the trimmer cannot statically analyze the object's type so its members may be trimmed.")]
public static object? Get(this Microsoft.Extensions.Configuration.IConfiguration configuration, Type type);
public static object? Get(this Microsoft.Extensions.Configuration.IConfiguration configuration, Type type);
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Binding strongly typed objects to configuration values requires generating dynamic code at runtime, for example instantiating generic types.")>]
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("In case the type is non-primitive, the trimmer cannot statically analyze the object's type so its members may be trimmed.")>]
static member Get : Microsoft.Extensions.Configuration.IConfiguration * Type -> obj
static member Get : Microsoft.Extensions.Configuration.IConfiguration * Type -> obj
<Extension()>
Public Function Get (configuration As IConfiguration, type As Type) As Object

参数

configuration
IConfiguration

要绑定的配置实例。

type
Type

要绑定的新实例的类型。

返回

如果成功,则为 null,否则为 null。

属性

适用于

Get(IConfiguration, Type, Action<BinderOptions>)

Source:
ConfigurationBinder.cs
Source:
ConfigurationBinder.cs
Source:
ConfigurationBinder.cs
Source:
ConfigurationBinder.cs

尝试将配置实例绑定到 T 类型的新实例。如果此配置节具有一个值,将使用该值。 否则,通过以递归方式将属性名称与配置键匹配来绑定。

public:
[System::Runtime::CompilerServices::Extension]
 static System::Object ^ Get(Microsoft::Extensions::Configuration::IConfiguration ^ configuration, Type ^ type, Action<Microsoft::Extensions::Configuration::BinderOptions ^> ^ configureOptions);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Binding strongly typed objects to configuration values requires generating dynamic code at runtime, for example instantiating generic types.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("In case the type is non-primitive, the trimmer cannot statically analyze the object's type so its members may be trimmed.")]
public static object? Get(this 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);
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Binding strongly typed objects to configuration values requires generating dynamic code at runtime, for example instantiating generic types.")>]
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("In case the type is non-primitive, the trimmer cannot statically analyze the object's type so its members may be trimmed.")>]
static member Get : Microsoft.Extensions.Configuration.IConfiguration * Type * Action<Microsoft.Extensions.Configuration.BinderOptions> -> obj
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

要绑定的配置实例。

type
Type

要绑定的新实例的类型。

configureOptions
Action<BinderOptions>

配置绑定器选项。

返回

如果成功,则为 null,否则为 null。

属性

适用于

Get<T>(IConfiguration)

Source:
ConfigurationBinder.cs
Source:
ConfigurationBinder.cs
Source:
ConfigurationBinder.cs
Source:
ConfigurationBinder.cs

尝试将配置实例绑定到 T 类型的新实例。如果此配置节具有一个值,将使用该值。 否则,通过以递归方式将属性名称与配置键匹配来绑定。

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static T Get(Microsoft::Extensions::Configuration::IConfiguration ^ configuration);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Binding strongly typed objects to configuration values requires generating dynamic code at runtime, for example instantiating generic types.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("In case the type is non-primitive, the trimmer cannot statically analyze the object's type so its members may be trimmed.")]
public static T? Get<T>(this Microsoft.Extensions.Configuration.IConfiguration configuration);
public static T? Get<T>(this Microsoft.Extensions.Configuration.IConfiguration configuration);
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Binding strongly typed objects to configuration values requires generating dynamic code at runtime, for example instantiating generic types.")>]
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("In case the type is non-primitive, the trimmer cannot statically analyze the object's type so its members may be trimmed.")>]
static member Get : Microsoft.Extensions.Configuration.IConfiguration -> 'T
static member Get : Microsoft.Extensions.Configuration.IConfiguration -> 'T
<Extension()>
Public Function Get(Of T) (configuration As IConfiguration) As T

类型参数

T

要绑定的新实例的类型。

参数

configuration
IConfiguration

要绑定的配置实例。

返回

T

如果成功,则为 T 的新实例,否则为 default(T)。

属性

适用于

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

Source:
ConfigurationBinder.cs
Source:
ConfigurationBinder.cs
Source:
ConfigurationBinder.cs
Source:
ConfigurationBinder.cs

尝试将配置实例绑定到 T 类型的新实例。如果此配置节具有一个值,将使用该值。 否则,通过以递归方式将属性名称与配置键匹配来绑定。

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static T Get(Microsoft::Extensions::Configuration::IConfiguration ^ configuration, Action<Microsoft::Extensions::Configuration::BinderOptions ^> ^ configureOptions);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Binding strongly typed objects to configuration values requires generating dynamic code at runtime, for example instantiating generic types.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("In case the type is non-primitive, the trimmer cannot statically analyze the object's type so its members may be trimmed.")]
public static T? Get<T>(this 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);
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Binding strongly typed objects to configuration values requires generating dynamic code at runtime, for example instantiating generic types.")>]
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("In case the type is non-primitive, the trimmer cannot statically analyze the object's type so its members may be trimmed.")>]
static member Get : Microsoft.Extensions.Configuration.IConfiguration * Action<Microsoft.Extensions.Configuration.BinderOptions> -> 'T
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

要绑定的新实例的类型。

参数

configuration
IConfiguration

要绑定的配置实例。

configureOptions
Action<BinderOptions>

配置绑定器选项。

返回

T

如果成功,则为 T 的新实例,否则为 default(T)。

属性

适用于