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:
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:
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:
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:
Return type:

T

Returns:

The converted value.

public static T GetValue<T>(this IConfiguration configuration, string key, T defaultValue)