ConfigurationBinder Class¶
Static helper class that allows binding strongly typed objects to configuration values.
- Namespace
Microsoft.Extensions.Configuration
- Assemblies
- Microsoft.Extensions.Configuration.Binder
Syntax¶
public class ConfigurationBinder
-
class
Microsoft.Extensions.Configuration.
ConfigurationBinder
Methods¶
-
Bind
(Microsoft.Extensions.Configuration.IConfiguration, System.Object)¶ Attempts to bind the given object instance to configuration values by matching property names against configuration keys recursively.
Arguments: - configuration (Microsoft.Extensions.Configuration.IConfiguration) – The configuration instance to bind.
- instance (System.Object) – The object to bind.
public static void Bind(this IConfiguration configuration, object instance)
-
GetValue
(Microsoft.Extensions.Configuration.IConfiguration, System.Type, System.String)¶ Extracts the value with the specified key and converts it to the specified type.
Arguments: - configuration (Microsoft.Extensions.Configuration.IConfiguration) – The configuration.
- type (System.Type) – The type to convert the value to.
- key (System.String) – The configuration key for the value to convert.
Return type: System.Object
Returns: The converted value.
public static object GetValue(this IConfiguration configuration, Type type, string key)
-
GetValue
(Microsoft.Extensions.Configuration.IConfiguration, System.Type, System.String, System.Object) Extracts the value with the specified key and converts it to the specified type.
Arguments: - configuration (Microsoft.Extensions.Configuration.IConfiguration) – The configuration.
- type (System.Type) – The type to convert the value to.
- key (System.String) – The configuration key for the value to convert.
- defaultValue (System.Object) – The default value to use if no value is found.
Return type: System.Object
Returns: The converted value.
public static object GetValue(this IConfiguration configuration, Type type, string key, object defaultValue)
-
GetValue<T>
(Microsoft.Extensions.Configuration.IConfiguration, System.String)¶ Extracts the value with the specified key and converts it to type T.
Arguments: - configuration (Microsoft.Extensions.Configuration.IConfiguration) – The configuration.
- key (System.String) – The configuration key for the value to convert.
Return type: T
Returns: The converted value.
public static T GetValue<T>(this IConfiguration configuration, string key)
-
GetValue<T>
(Microsoft.Extensions.Configuration.IConfiguration, System.String, T) Extracts the value with the specified key and converts it to type T.
Arguments: - configuration (Microsoft.Extensions.Configuration.IConfiguration) – The configuration.
- key (System.String) – The configuration key for the value to convert.
- defaultValue (T) – The default value to use if no value is found.
Return type: T
Returns: The converted value.
public static T GetValue<T>(this IConfiguration configuration, string key, T defaultValue)
-