<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="10.0.0-preview.3.25171.5" />

ConfigurationExtensions

public static class ConfigurationExtensions
Provides extension methods for configuration classes.
using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Runtime.CompilerServices; namespace Microsoft.Extensions.Configuration { [System.Runtime.CompilerServices.NullableContext(1)] [System.Runtime.CompilerServices.Nullable(0)] public static class ConfigurationExtensions { public static IConfigurationBuilder Add<[System.Runtime.CompilerServices.Nullable(0)] TSource>(this IConfigurationBuilder builder, [System.Runtime.CompilerServices.Nullable(new byte[] { 2, 1 })] Action<TSource> configureSource) where TSource : IConfigurationSource, new { TSource val = new TSource(); configureSource?.Invoke(val); return builder.Add((IConfigurationSource)(object)val); } [return: System.Runtime.CompilerServices.Nullable(2)] public static string GetConnectionString(this IConfiguration configuration, string name) { return configuration?.GetSection("ConnectionStrings")[name]; } [return: System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0, 1, 2 })] public static IEnumerable<KeyValuePair<string, string>> AsEnumerable(this IConfiguration configuration) { return configuration.AsEnumerable(false); } [IteratorStateMachine(typeof(<AsEnumerable>d__3))] [return: System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0, 1, 2 })] public static IEnumerable<KeyValuePair<string, string>> AsEnumerable(this IConfiguration configuration, bool makePathsRelative) { <AsEnumerable>d__3 <AsEnumerable>d__ = new <AsEnumerable>d__3(-2); <AsEnumerable>d__.<>3__configuration = configuration; <AsEnumerable>d__.<>3__makePathsRelative = makePathsRelative; return <AsEnumerable>d__; } [System.Runtime.CompilerServices.NullableContext(2)] public static bool Exists([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] this IConfigurationSection section) { if (section == null) return false; if (section.Value == null) return section.GetChildren().Any(); return true; } public static IConfigurationSection GetRequiredSection(this IConfiguration configuration, string key) { System.ThrowHelper.ThrowIfNull(configuration, "configuration"); IConfigurationSection section = configuration.GetSection(key); if (section.Exists()) return section; throw new InvalidOperationException(System.SR.Format(System.SR.InvalidSectionName, key)); } } }