/// <summary> /// 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. /// </summary> /// <typeparam name="T">The type of the new instance to bind.</typeparam> /// <param name="configuration">The configuration instance to bind.</param> /// <param name="configureOptions">Configures the binder options.</param> /// <returns>The new instance of T if successful, default(T) otherwise.</returns> public static T Get <T>(this IAppConfiguration configuration, Action <AppConfigurationBinderOptions> configureOptions) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } var result = configuration.Get(typeof(T), configureOptions); if (result == null) { return(default);
/// <summary> /// 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. /// </summary> /// <typeparam name="T">The type of the new instance to bind.</typeparam> /// <param name="configuration">The configuration instance to bind.</param> /// <returns>The new instance of T if successful, default(T) otherwise.</returns> public static T Get <T>(this IAppConfiguration configuration) { return(configuration.Get <T>(_ => { })); }