/// <summary> /// Loads the configuration section based on the name of the type of T. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="config">The configuration.</param> /// <returns>T.</returns> public static T LoadSection <T>(this IConfigurationRoot config) where T : class, new() { if (config is null) { throw new System.ArgumentNullException(nameof(config)); } config.Bind(TypeExtensions.Create <T>()); return(config.GetSection(typeof(T).Name).Get <T>()); }
/// <summary> /// Loads the configuration section based on the name of the type of T. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="config">The configuration.</param> /// <returns>T.</returns> public static T LoadSection <T>(this IConfigurationRoot config) where T : class, new() { config.Bind(TypeExtensions.Create <T>()); return(config.GetSection(typeof(T).Name).Get <T>()); }