/// <summary> /// Gets a configuration value from a scope and name. /// </summary> /// <typeparam name="T">Type of the returned value.</typeparam> /// <param name="configuration">Configuration containing a list of key-value pairs.</param> /// <param name="scope">Scope of the configuration.</param> /// <param name="name">Name of the scope.</param> /// <param name="valueConverter">A <see cref="ISettingValueConverter{T}"/> that converts configuration value literals to the type <typeparamref name="T"/>.</param> /// <returns>A configuration value of the type <typeparamref name="T"/></returns> public static T GetScopeValue <T>(this IConfiguration configuration, string scope, string name, ISettingValueConverter <T> valueConverter = null) { string key = ConfigurationUtility.MergeToKey(scope, name); T rtn = GetValue(configuration, key, valueConverter); return(rtn); }
/// <summary> /// Gets a configuration value list from a scope and name. Returns <paramref name="defaultValueList"/> if no key was found. /// </summary> /// <typeparam name="T">Type of the returned value.</typeparam> /// <param name="configuration">Configuration containing a list of key-list of value.</param> /// <param name="scope">Scope of the configuration.</param> /// <param name="name">Name of the scope.</param> /// <param name="defaultValueList">Default value list to return if no key is found.</param> /// <param name="valueConverter">A <see cref="ISettingValueConverter{T}"/> that converts configuration value literals to the type <typeparamref name="T"/>.</param> /// <returns>A <see cref="IEnumerable{T}"/>.</returns> public static IEnumerable <T> GetScopeValueList <T>(this IConfiguration configuration, string scope, string name, IEnumerable <T> defaultValueList, ISettingValueConverter <T> valueConverter = null) { string key = ConfigurationUtility.MergeToKey(scope, name); IEnumerable <T> rtn = GetValueList(configuration, key, defaultValueList, valueConverter); return(rtn); }