Table of Contents

Class ConfigurationBinder

Namespace
Acuit.Pinpoint.Configuration
Assembly
Acuit.Pinpoint.Configuration.dll

Static helper class that allows binding strongly typed objects to configuration values.

public static class ConfigurationBinder
Inheritance
ConfigurationBinder
Inherited Members

Methods

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)

Parameters

configuration IConfiguration

The configuration instance to bind.

instance object

The object to bind.

Bind(IConfiguration, string, object)

Attempts to bind the given object instance to the configuration section specified by the key by matching property names against configuration keys recursively.

public static void Bind(this IConfiguration configuration, string key, object instance)

Parameters

configuration IConfiguration

The configuration instance to bind.

key string

The key of the configuration section to bind.

instance object

The object to bind.

Get(IConfiguration, Type)

Attempts to bind the configuration instance to a new instance of type T. If this configuration section has a value, that will be used. Otherwise binding by matching property names against configuration keys recursively.

public static object Get(this IConfiguration configuration, Type type)

Parameters

configuration IConfiguration

The configuration instance to bind.

type Type

The type of the new instance to bind.

Returns

object

The new instance if successful, null otherwise.

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)

Parameters

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.

Returns

object

The converted value.

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)

Parameters

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.

Returns

object

The converted value.

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

Parameters

configuration IConfiguration

The configuration.

key string

The key of the configuration section's value to convert.

Returns

T

The converted value.

Type Parameters

T

The type to convert the value to.

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

Parameters

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.

Returns

T

The converted value.

Type Parameters

T

The type to convert the value to.

Get<T>(IConfiguration)

Attempts to bind the configuration instance to a new instance of type T. If this configuration section has a value, that will be used. Otherwise binding by matching property names against configuration keys recursively.

public static T Get<T>(this IConfiguration configuration)

Parameters

configuration IConfiguration

The configuration instance to bind.

Returns

T

The new instance of T if successful, default(T) otherwise.

Type Parameters

T

The type of the new instance to bind.