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

ConfigurationProvider

Defines the core behavior of configuration providers and provides a base for derived classes.
using Microsoft.Extensions.Primitives; using System; using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Threading; namespace Microsoft.Extensions.Configuration { [System.Runtime.CompilerServices.NullableContext(1)] [System.Runtime.CompilerServices.Nullable(0)] public abstract class ConfigurationProvider : IConfigurationProvider { private ConfigurationReloadToken _reloadToken = new ConfigurationReloadToken(); [System.Runtime.CompilerServices.Nullable(new byte[] { 1, 1, 2 })] protected IDictionary<string, string> Data { [return: System.Runtime.CompilerServices.Nullable(new byte[] { 1, 1, 2 })] get; [param: System.Runtime.CompilerServices.Nullable(new byte[] { 1, 1, 2 })] set; } protected ConfigurationProvider() { Data = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); } public virtual bool TryGet(string key, [System.Runtime.CompilerServices.Nullable(2)] out string value) { return Data.TryGetValue(key, out value); } public virtual void Set(string key, [System.Runtime.CompilerServices.Nullable(2)] string value) { Data[key] = value; } public virtual void Load() { } public virtual IEnumerable<string> GetChildKeys(IEnumerable<string> earlierKeys, [System.Runtime.CompilerServices.Nullable(2)] string parentPath) { List<string> list = new List<string>(); if (parentPath == null) { foreach (KeyValuePair<string, string> datum in Data) { list.Add(Segment(datum.Key, 0)); } } else { foreach (KeyValuePair<string, string> datum2 in Data) { if (datum2.Key.Length > parentPath.Length && datum2.Key.StartsWith(parentPath, StringComparison.OrdinalIgnoreCase) && datum2.Key[parentPath.Length] == ':') list.Add(Segment(datum2.Key, parentPath.Length + 1)); } } list.AddRange(earlierKeys); list.Sort(ConfigurationKeyComparer.Comparison); return list; } private static string Segment(string key, int prefixLength) { int num = key.IndexOf(':', prefixLength); if (num >= 0) return key.Substring(prefixLength, num - prefixLength); return key.Substring(prefixLength); } public IChangeToken GetReloadToken() { return _reloadToken; } protected void OnReload() { Interlocked.Exchange(ref _reloadToken, new ConfigurationReloadToken()).OnReload(); } public override string ToString() { return GetType().Name; } } }