ConfigurationBinder.GetValue 方法

定義

多載

GetValue(IConfiguration, Type, String)

使用指定的索引鍵來擷取值,並將其轉換為指定的類型。Extracts the value with the specified key and converts it to the specified type.

GetValue(IConfiguration, Type, String, Object)

使用指定的索引鍵來擷取值,並將其轉換為指定的類型。Extracts the value with the specified key and converts it to the specified type.

GetValue<T>(IConfiguration, String)

使用指定的索引鍵來擷取值,並將其轉換成類型 T。Extracts the value with the specified key and converts it to type T.

GetValue<T>(IConfiguration, String, T)

使用指定的索引鍵來擷取值,並將其轉換成類型 T。Extracts the value with the specified key and converts it to type T.

GetValue(IConfiguration, Type, String)

使用指定的索引鍵來擷取值,並將其轉換為指定的類型。Extracts the value with the specified key and converts it to the specified type.

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);
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

組態。The configuration.

type
Type

要將值轉換成的型別。The type to convert the value to.

key
String

所要轉換組態區段值的索引鍵。The key of the configuration section's value to convert.

傳回

Object

轉換的值。The converted value.

適用於

GetValue(IConfiguration, Type, String, Object)

使用指定的索引鍵來擷取值,並將其轉換為指定的類型。Extracts the value with the specified key and converts it to the specified type.

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);
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

組態。The configuration.

type
Type

要將值轉換成的型別。The type to convert the value to.

key
String

所要轉換組態區段值的索引鍵。The key of the configuration section's value to convert.

defaultValue
Object

如果找不到任何值時要使用的預設值。The default value to use if no value is found.

傳回

Object

轉換的值。The converted value.

適用於

GetValue<T>(IConfiguration, String)

使用指定的索引鍵來擷取值,並將其轉換成類型 T。Extracts the value with the specified key and converts it to type 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);
static member GetValue : Microsoft.Extensions.Configuration.IConfiguration * string -> 'T
<Extension()>
Public Function GetValue(Of T) (configuration As IConfiguration, key As String) As T

類型參數

T

要將值轉換成的型別。The type to convert the value to.

參數

configuration
IConfiguration

組態。The configuration.

key
String

所要轉換組態區段值的索引鍵。The key of the configuration section's value to convert.

傳回

T

轉換的值。The converted value.

適用於

GetValue<T>(IConfiguration, String, T)

使用指定的索引鍵來擷取值,並將其轉換成類型 T。Extracts the value with the specified key and converts it to type 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);
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

要將值轉換成的型別。The type to convert the value to.

參數

configuration
IConfiguration

組態。The configuration.

key
String

所要轉換組態區段值的索引鍵。The key of the configuration section's value to convert.

defaultValue
T

如果找不到任何值時要使用的預設值。The default value to use if no value is found.

傳回

T

轉換的值。The converted value.

適用於