<PackageReference Include="System.Configuration.ConfigurationManager" Version="10.0.0-preview.1.25080.5" />

ProviderSettings

public sealed class ProviderSettings : ConfigurationElement
Represents the configuration elements associated with a provider.
using System.Collections; using System.Collections.Specialized; namespace System.Configuration { public sealed class ProviderSettings : ConfigurationElement { private readonly ConfigurationPropertyCollection _properties; private readonly ConfigurationProperty _propName = new ConfigurationProperty("name", typeof(string), null, null, ConfigurationProperty.s_nonEmptyStringValidator, ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey); private readonly ConfigurationProperty _propType = new ConfigurationProperty("type", typeof(string), "", ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsTypeStringTransformationRequired); private NameValueCollection _propertyNameCollection; protected internal override ConfigurationPropertyCollection Properties { get { UpdatePropertyCollection(); return _properties; } } [ConfigurationProperty("name", IsRequired = true, IsKey = true)] public string Name { get { return (string)base[_propName]; } set { base[_propName] = value; } } [ConfigurationProperty("type", IsRequired = true)] public string Type { get { return (string)base[_propType]; } set { base[_propType] = value; } } public NameValueCollection Parameters { get { if (_propertyNameCollection != null) return _propertyNameCollection; lock (this) { _propertyNameCollection = new NameValueCollection(StringComparer.Ordinal); foreach (ConfigurationProperty property in _properties) { if (property.Name != "name" && property.Name != "type") _propertyNameCollection.Add(property.Name, (string)base[property]); } } return _propertyNameCollection; } } public ProviderSettings() { _properties = new ConfigurationPropertyCollection { _propName, _propType }; _propertyNameCollection = null; } public ProviderSettings(string name, string type) : this() { Name = name; Type = type; } protected internal override void Unmerge(ConfigurationElement sourceElement, ConfigurationElement parentElement, ConfigurationSaveMode saveMode) { (parentElement as ProviderSettings)?.UpdatePropertyCollection(); (sourceElement as ProviderSettings)?.UpdatePropertyCollection(); base.Unmerge(sourceElement, parentElement, saveMode); UpdatePropertyCollection(); } protected internal override void Reset(ConfigurationElement parentElement) { (parentElement as ProviderSettings)?.UpdatePropertyCollection(); base.Reset(parentElement); } internal bool UpdatePropertyCollection() { bool result = false; ArrayList arrayList = null; if (_propertyNameCollection != null) { foreach (ConfigurationProperty property2 in _properties) { if (property2.Name != "name" && property2.Name != "type" && _propertyNameCollection.Get(property2.Name) == null) { if (arrayList == null) arrayList = new ArrayList(); if ((base.Values.GetConfigValue(property2.Name).ValueFlags & ConfigurationValueFlags.Locked) == ConfigurationValueFlags.Default) { arrayList.Add(property2.Name); result = true; } } } if (arrayList != null) { foreach (string item in arrayList) { _properties.Remove(item); } } foreach (string item2 in _propertyNameCollection) { string text2 = _propertyNameCollection[item2]; string property = GetProperty(item2); if (property == null || text2 != property) { SetProperty(item2, text2); result = true; } } } _propertyNameCollection = null; return result; } protected internal override bool IsModified() { if (!UpdatePropertyCollection()) return base.IsModified(); return true; } private string GetProperty(string propName) { if (_properties.Contains(propName)) { ConfigurationProperty configurationProperty = _properties[propName]; if (configurationProperty != null) return (string)base[configurationProperty]; } return null; } private void SetProperty(string propName, string value) { ConfigurationProperty configurationProperty; if (_properties.Contains(propName)) configurationProperty = _properties[propName]; else { configurationProperty = new ConfigurationProperty(propName, typeof(string), null); _properties.Add(configurationProperty); } if (configurationProperty != null) base[configurationProperty] = value; } protected override bool OnDeserializeUnrecognizedAttribute(string name, string value) { ConfigurationProperty configurationProperty = new ConfigurationProperty(name, typeof(string), value); _properties.Add(configurationProperty); base[configurationProperty] = value; Parameters[name] = value; return true; } } }