Configuration​Binder Configuration​Binder Class

Definition

Static helper class that allows binding strongly typed objects to configuration values.
public static class ConfigurationBinder : objectPublic Module ConfigurationBinder
    Inherits Object
Inheritance
System.ObjectSystem.Object
ConfigurationBinderConfigurationBinder

Methods

Bind(IConfiguration, Object) Bind(IConfiguration, Object)

Attempts to bind the given object instance to configuration values by matching property names against configuration keys recursively.
public static void Bind(this IConfiguration configuration, object instance)<ExtensionAttribute>
Public Shared Sub Bind(configuration As IConfiguration, instance As Object)
Parameters
configuration
IConfiguration IConfiguration
The configuration instance to bind.
instance
System.Object System.Object
The object to bind.

GetValue(IConfiguration, Type, String) GetValue(IConfiguration, Type, String)

Extracts the value with the specified key and converts it to the specified type.
public static object GetValue(this IConfiguration configuration, Type type, string key)<ExtensionAttribute>
Public Shared Function GetValue(configuration As IConfiguration, type As Type, key As String) As Object
Parameters
configuration
IConfiguration IConfiguration
The configuration.
type
Type Type
The type to convert the value to.
key
System.String System.String
The configuration key for the value to convert.
Returns
System.Object System.Object
The converted value.

GetValue(IConfiguration, Type, String, Object) GetValue(IConfiguration, Type, String, Object)

Extracts the value with the specified key and converts it to the specified type.
public static object GetValue(this IConfiguration configuration, Type type, string key, object defaultValue)<ExtensionAttribute>
Public Shared Function GetValue(configuration As IConfiguration, type As Type, key As String, defaultValue As Object) As Object
Parameters
configuration
IConfiguration IConfiguration
The configuration.
type
Type Type
The type to convert the value to.
key
System.String System.String
The configuration key for the value to convert.
defaultValue
System.Object System.Object
The default value to use if no value is found.
Returns
System.Object System.Object
The converted value.

GetValue<T>(IConfiguration, String) GetValue(Of T)(IConfiguration, String)

Extracts the value with the specified key and converts it to type T.
public static T GetValue<T>(this IConfiguration configuration, string key)<ExtensionAttribute>
Public Shared Function GetValue(Of T)(configuration As IConfiguration, key As String) As T
Type Parameters
T
The type to convert the value to.
Parameters
configuration
IConfiguration IConfiguration
The configuration.
key
System.String System.String
The configuration key for the value to convert.
Returns
T T
The converted value.

GetValue<T>(IConfiguration, String, T) GetValue(Of T)(IConfiguration, String, T)

Extracts the value with the specified key and converts it to type T.
public static T GetValue<T>(this IConfiguration configuration, string key, T defaultValue)<ExtensionAttribute>
Public Shared Function GetValue(Of T)(configuration As IConfiguration, key As String, defaultValue As T) As T
Type Parameters
T
The type to convert the value to.
Parameters
configuration
IConfiguration IConfiguration
The configuration.
key
System.String System.String
The configuration key for the value to convert.
defaultValue
T T
The default value to use if no value is found.
Returns
T T
The converted value.