ConfigurationBinder.GetValue 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
| 名稱 | Description |
|---|---|
| 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);
[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? 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);
[<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 GetValue : Microsoft.Extensions.Configuration.IConfiguration * Type * string -> obj
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
設定區段的值數值是要轉換的關鍵。
傳回
換算後的價值。
- 屬性
適用於
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);
[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? 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);
[<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 GetValue : Microsoft.Extensions.Configuration.IConfiguration * Type * string * obj -> obj
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
如果找不到任何值,則預設值會用。
傳回
換算後的價值。
- 屬性
適用於
GetValue<T>(IConfiguration, String)
用指定鍵提取值並轉換成 T 型。
public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
static T GetValue(Microsoft::Extensions::Configuration::IConfiguration ^ configuration, System::String ^ key);
[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? GetValue<T>(this Microsoft.Extensions.Configuration.IConfiguration configuration, string key);
public static T? GetValue<T>(this Microsoft.Extensions.Configuration.IConfiguration configuration, string key);
[<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 GetValue : Microsoft.Extensions.Configuration.IConfiguration * string -> 'T
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);
[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? 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);
[<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 GetValue : Microsoft.Extensions.Configuration.IConfiguration * string * 'T -> 'T
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
換算後的價值。
- 屬性