/// <summary> /// Builds a hierarchical dictionary of the key/value pairs represented by the given <see cref="IConfigurationProvider"/> instance. /// </summary> /// <param name="provider">The <see cref="IConfigurationProvider"/> instance from which to construct the dictionary.</param> /// <returns>A hierarchical dictionary of the key/value pairs in the given <see cref="IConfigurationProvider"/> instance.</returns> internal static IDictionary <string, object> ToNestedDictionary(this IConfigurationProvider provider) { if (provider == null) { throw new ArgumentNullException(nameof(provider)); } using (var config = new ConfigurationRoot(new[] { provider })) return(config.ToNestedDictionary()); }