ConfigurationBinder.GetValue 方法

定义

重载

GetValue(IConfiguration, Type, String)

提取具有指定键的值,并将其转换为指定的类型。

GetValue(IConfiguration, Type, String, Object)

提取具有指定键的值,并将其转换为指定的类型。

GetValue<T>(IConfiguration, String)

提取具有指定键的值,并将其转换为 T 类型。

GetValue<T>(IConfiguration, String, T)

提取具有指定键的值,并将其转换为 T 类型。

GetValue(IConfiguration, Type, String)

提取具有指定键的值,并将其转换为指定的类型。

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

参数

configuration
IConfiguration

配置。

type
Type

要将值转换到的类型。

key
String

要转换的配置节值的键。

返回

Object

转换后的值。

适用于

GetValue(IConfiguration, Type, String, Object)

提取具有指定键的值,并将其转换为指定的类型。

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

参数

configuration
IConfiguration

配置。

type
Type

要将值转换到的类型。

key
String

要转换的配置节值的键。

defaultValue
Object

未找到任何值时可使用的默认值。

返回

Object

转换后的值。

适用于

GetValue<T>(IConfiguration, String)

提取具有指定键的值,并将其转换为 T 类型。

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

类型参数

T

要将值转换到的类型。

参数

configuration
IConfiguration

配置。

key
String

要转换的配置节值的键。

返回

T

转换后的值。

适用于

GetValue<T>(IConfiguration, String, T)

提取具有指定键的值,并将其转换为 T 类型。

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static T GetValue(Microsoft::Extensions::Configuration::IConfiguration ^ configuration, System::String ^ key, T defaultValue);
public static T GetValue<T> (this Microsoft.Extensions.Configuration.IConfiguration configuration, string key, T defaultValue);
public static T? GetValue<T> (this Microsoft.Extensions.Configuration.IConfiguration configuration, string key, T defaultValue);
static member GetValue : Microsoft.Extensions.Configuration.IConfiguration * string * 'T -> 'T
<Extension()>
Public Function GetValue(Of T) (configuration As IConfiguration, key As String, defaultValue As T) As T

类型参数

T

要将值转换到的类型。

参数

configuration
IConfiguration

配置。

key
String

要转换的配置节值的键。

defaultValue
T

未找到任何值时可使用的默认值。

返回

T

转换后的值。

适用于