<PackageReference Include="System.Configuration.ConfigurationManager" Version="7.0.0-preview.4.22229.4" />

KeyValueConfigurationElement

namespace System.Configuration { public class KeyValueConfigurationElement : ConfigurationElement { private static readonly ConfigurationProperty s_propKey = new ConfigurationProperty("key", typeof(string), string.Empty, ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey); private static readonly ConfigurationProperty s_propValue = new ConfigurationProperty("value", typeof(string), string.Empty, ConfigurationPropertyOptions.None); private static readonly ConfigurationPropertyCollection s_properties = new ConfigurationPropertyCollection { s_propKey, s_propValue }; private readonly string _initKey; private readonly string _initValue; private bool _needsInit; protected internal override ConfigurationPropertyCollection Properties => s_properties; [ConfigurationProperty("key", Options = ConfigurationPropertyOptions.IsKey, DefaultValue = "")] public string Key { get { return (string)base[s_propKey]; } } [ConfigurationProperty("value", DefaultValue = "")] public string Value { get { return (string)base[s_propValue]; } set { base[s_propValue] = value; } } internal KeyValueConfigurationElement() { } public KeyValueConfigurationElement(string key, string value) { _needsInit = true; _initKey = key; _initValue = value; } protected internal override void Init() { base.Init(); if (_needsInit) { _needsInit = false; base[s_propKey] = _initKey; Value = _initValue; } } } }