Ejemplo n.º 1
0
        /// <summary>
        /// Builds a flat 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 flat dictionary of the key/value pairs in the given <see cref="IConfigurationProvider"/> instance.</returns>
        internal static IDictionary <string, string> ToDictionary(this IConfigurationProvider provider)
        {
            if (provider == null)
            {
                throw new ArgumentNullException(nameof(provider));
            }

            using (var config = new ConfigurationRoot(new[] { provider }))
                return(config.ToDictionary());
        }