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

ConfigurationSection

Represents a section of application configuration values.
using Microsoft.Extensions.Primitives; using System; using System.Collections.Generic; using System.Diagnostics; using System.Runtime.CompilerServices; namespace Microsoft.Extensions.Configuration { [NullableContext(1)] [Nullable(0)] [DebuggerDisplay("{DebuggerToString(),nq}")] [DebuggerTypeProxy(typeof(ConfigurationSectionDebugView))] public class ConfigurationSection : IConfigurationSection, IConfiguration { private sealed class ConfigurationSectionDebugView { private readonly ConfigurationSection _current; private readonly IConfigurationProvider _provider; public string Path => _current.Path; public string Key => _current.Key; public string Value => _current.Value; public IConfigurationProvider Provider => _provider; public List<Microsoft.Extensions.Configuration.ConfigurationSectionDebugView> Sections => Microsoft.Extensions.Configuration.ConfigurationSectionDebugView.FromConfiguration(_current, _current._root); public ConfigurationSectionDebugView(ConfigurationSection current) { _current = current; _provider = Microsoft.Extensions.Configuration.ConfigurationSectionDebugView.GetValueProvider(_current._root, _current.Path); } } private readonly IConfigurationRoot _root; private readonly string _path; private string _key; public string Path => _path; public string Key => _key ?? (_key = ConfigurationPath.GetSectionKey(_path)); [Nullable(2)] public string Value { [NullableContext(2)] get { return _root[Path]; } [NullableContext(2)] set { _root[Path] = value; } } [Nullable(2)] public string this[string key] { [return: Nullable(2)] get { return _root[Path + ConfigurationPath.KeyDelimiter + key]; } [param: Nullable(2)] set { _root[Path + ConfigurationPath.KeyDelimiter + key] = value; } } public ConfigurationSection(IConfigurationRoot root, string path) { System.ThrowHelper.ThrowIfNull(root, "root"); System.ThrowHelper.ThrowIfNull(path, "path"); _root = root; _path = path; } public IConfigurationSection GetSection(string key) { return _root.GetSection(Path + ConfigurationPath.KeyDelimiter + key); } public IEnumerable<IConfigurationSection> GetChildren() { return _root.GetChildrenImplementation(Path); } public IChangeToken GetReloadToken() { return _root.GetReloadToken(); } private string DebuggerToString() { string text = "Path = " + Path; int count = Microsoft.Extensions.Configuration.ConfigurationSectionDebugView.FromConfiguration(this, _root).Count; DefaultInterpolatedStringHandler defaultInterpolatedStringHandler; if (count > 0) { string str = text; defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(13, 1); defaultInterpolatedStringHandler.AppendLiteral(", Sections = "); defaultInterpolatedStringHandler.AppendFormatted(count); text = str + defaultInterpolatedStringHandler.ToStringAndClear(); } if (Value != null) { text = text + ", Value = " + Value; IConfigurationProvider valueProvider = Microsoft.Extensions.Configuration.ConfigurationSectionDebugView.GetValueProvider(_root, Path); if (valueProvider != null) { string str2 = text; defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(13, 1); defaultInterpolatedStringHandler.AppendLiteral(", Provider = "); defaultInterpolatedStringHandler.AppendFormatted(valueProvider); text = str2 + defaultInterpolatedStringHandler.ToStringAndClear(); } } return text; } } }