<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.4.1" />

FactoryRecord

using System.Collections.Generic; using System.Configuration.Internal; using System.Diagnostics; namespace System.Configuration { [DebuggerDisplay("FactoryRecord {ConfigKey}")] internal class FactoryRecord : IConfigErrorInfo { private const int FlagAllowLocation = 1; private const int FlagRestartOnExternalChanges = 2; private const int FlagRequirePermission = 4; private const int FlagIsGroup = 8; private const int FlagIsFromTrustedConfigRecord = 16; private const int FlagIsUndeclared = 64; private List<ConfigurationException> _errors; private SimpleBitVector32 _flags; internal string ConfigKey { get; } internal string Group { get; } internal string Name { get; } internal object Factory { get; set; } internal string FactoryTypeName { get; set; } internal ConfigurationAllowDefinition AllowDefinition { get; set; } internal ConfigurationAllowExeDefinition AllowExeDefinition { get; set; } internal OverrideModeSetting OverrideModeDefault { get; } internal bool AllowLocation { get { return _flags[1]; } set { _flags[1] = value; } } internal bool RestartOnExternalChanges { get { return _flags[2]; } set { _flags[2] = value; } } internal bool RequirePermission { get { return _flags[4]; } set { _flags[4] = value; } } internal bool IsGroup { get { return _flags[8]; } set { _flags[8] = value; } } internal bool IsFromTrustedConfigRecord { get { return _flags[16]; } set { _flags[16] = value; } } internal bool IsUndeclared { get { return _flags[64]; } set { _flags[64] = value; } } internal bool HasFile => LineNumber >= 0; internal List<ConfigurationException> Errors => _errors; internal bool HasErrors => ErrorsHelper.GetHasErrors(_errors); public string Filename { get; set; } public int LineNumber { get; set; } private FactoryRecord(string configKey, string group, string name, object factory, string factoryTypeName, SimpleBitVector32 flags, ConfigurationAllowDefinition allowDefinition, ConfigurationAllowExeDefinition allowExeDefinition, OverrideModeSetting overrideModeDefault, string filename, int lineNumber, ICollection<ConfigurationException> errors) { ConfigKey = configKey; Group = group; Name = name; Factory = factory; FactoryTypeName = factoryTypeName; _flags = flags; AllowDefinition = allowDefinition; AllowExeDefinition = allowExeDefinition; OverrideModeDefault = overrideModeDefault; Filename = filename; LineNumber = lineNumber; AddErrors(errors); } internal FactoryRecord(string configKey, string group, string name, string factoryTypeName, string filename, int lineNumber) { ConfigKey = configKey; Group = group; Name = name; FactoryTypeName = factoryTypeName; IsGroup = true; Filename = filename; LineNumber = lineNumber; } internal FactoryRecord(string configKey, string group, string name, string factoryTypeName, bool allowLocation, ConfigurationAllowDefinition allowDefinition, ConfigurationAllowExeDefinition allowExeDefinition, OverrideModeSetting overrideModeDefault, bool restartOnExternalChanges, bool requirePermission, bool isFromTrustedConfigRecord, bool isUndeclared, string filename, int lineNumber) { ConfigKey = configKey; Group = group; Name = name; FactoryTypeName = factoryTypeName; AllowDefinition = allowDefinition; AllowExeDefinition = allowExeDefinition; OverrideModeDefault = overrideModeDefault; AllowLocation = allowLocation; RestartOnExternalChanges = restartOnExternalChanges; RequirePermission = requirePermission; IsFromTrustedConfigRecord = isFromTrustedConfigRecord; IsUndeclared = isUndeclared; Filename = filename; LineNumber = lineNumber; } internal FactoryRecord CloneSection(string filename, int lineNumber) { return new FactoryRecord(ConfigKey, Group, Name, Factory, FactoryTypeName, _flags, AllowDefinition, AllowExeDefinition, OverrideModeDefault, filename, lineNumber, Errors); } internal FactoryRecord CloneSectionGroup(string factoryTypeName, string filename, int lineNumber) { if (FactoryTypeName != null) factoryTypeName = FactoryTypeName; return new FactoryRecord(ConfigKey, Group, Name, Factory, factoryTypeName, _flags, AllowDefinition, AllowExeDefinition, OverrideModeDefault, filename, lineNumber, Errors); } internal bool IsEquivalentType(IInternalConfigHost host, string typeName) { try { if (!(FactoryTypeName == typeName)) { Type type; Type type2; if (host != null) { type = TypeUtil.GetType(host, typeName, false); type2 = TypeUtil.GetType(host, FactoryTypeName, false); } else { type = TypeUtil.GetType(typeName, false); type2 = TypeUtil.GetType(FactoryTypeName, false); } return type != (Type)null && type == type2; } return true; } catch { } return false; } internal bool IsEquivalentSectionGroupFactory(IInternalConfigHost host, string typeName) { if (typeName == null || FactoryTypeName == null) return true; return IsEquivalentType(host, typeName); } internal bool IsEquivalentSectionFactory(IInternalConfigHost host, string typeName, bool allowLocation, ConfigurationAllowDefinition allowDefinition, ConfigurationAllowExeDefinition allowExeDefinition, bool restartOnExternalChanges, bool requirePermission) { if (allowLocation != AllowLocation || allowDefinition != AllowDefinition || allowExeDefinition != AllowExeDefinition || restartOnExternalChanges != RestartOnExternalChanges || requirePermission != RequirePermission) return false; return IsEquivalentType(host, typeName); } internal void AddErrors(ICollection<ConfigurationException> coll) { ErrorsHelper.AddErrors(ref _errors, coll); } internal void ThrowOnErrors() { ErrorsHelper.ThrowOnErrors(_errors); } internal bool IsIgnorable() { if (Factory != null) return Factory is IgnoreSectionHandler; if (FactoryTypeName != null) return FactoryTypeName.Contains("System.Configuration.IgnoreSection"); return false; } } }