mscorlib(4.0.0.0) API with additions
SettingElement.cs
1 using System.Xml;
2 
3 namespace System.Configuration
4 {
6  public sealed class SettingElement : ConfigurationElement
7  {
8  private static ConfigurationPropertyCollection _properties;
9 
10  private static readonly ConfigurationProperty _propName;
11 
12  private static readonly ConfigurationProperty _propSerializeAs;
13 
14  private static readonly ConfigurationProperty _propValue;
15 
16  private static XmlDocument doc;
17 
18  internal string Key => Name;
19 
20  protected internal override ConfigurationPropertyCollection Properties
21  {
22  protected get
23  {
24  return _properties;
25  }
26  }
27 
30  [ConfigurationProperty("name", IsRequired = true, IsKey = true, DefaultValue = "")]
31  public string Name
32  {
33  get
34  {
35  return (string)base[_propName];
36  }
37  set
38  {
39  base[_propName] = value;
40  }
41  }
42 
45  [ConfigurationProperty("serializeAs", IsRequired = true, DefaultValue = SettingsSerializeAs.String)]
47  {
48  get
49  {
50  return (SettingsSerializeAs)base[_propSerializeAs];
51  }
52  set
53  {
54  base[_propSerializeAs] = value;
55  }
56  }
57 
60  [ConfigurationProperty("value", IsRequired = true, DefaultValue = null)]
62  {
63  get
64  {
65  return (SettingValueElement)base[_propValue];
66  }
67  set
68  {
69  base[_propValue] = value;
70  }
71  }
72 
73  static SettingElement()
74  {
75  _propName = new ConfigurationProperty("name", typeof(string), "", ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey);
76  _propSerializeAs = new ConfigurationProperty("serializeAs", typeof(SettingsSerializeAs), SettingsSerializeAs.String, ConfigurationPropertyOptions.IsRequired);
77  _propValue = new ConfigurationProperty("value", typeof(SettingValueElement), null, ConfigurationPropertyOptions.IsRequired);
78  doc = new XmlDocument();
79  _properties = new ConfigurationPropertyCollection();
80  _properties.Add(_propName);
81  _properties.Add(_propSerializeAs);
82  _properties.Add(_propValue);
83  }
84 
86  public SettingElement()
87  {
88  }
89 
93  public SettingElement(string name, SettingsSerializeAs serializeAs)
94  : this()
95  {
96  Name = name;
97  SerializeAs = serializeAs;
98  }
99 
104  public override bool Equals(object settings)
105  {
106  SettingElement settingElement = settings as SettingElement;
107  if (settingElement != null && base.Equals(settings))
108  {
109  return object.Equals(settingElement.Value, Value);
110  }
111  return false;
112  }
113 
116  public override int GetHashCode()
117  {
118  return base.GetHashCode() ^ Value.GetHashCode();
119  }
120  }
121 }
Represents an XML document. You can use this class to load, validate, edit, add, and position XML in ...
Definition: XmlDocument.cs:13
string Name
Gets or sets the name of the T:System.Configuration.SettingElement object.
Definition: __Canon.cs:3
SettingValueElement Value
Gets or sets the value of a T:System.Configuration.SettingElement object by using a T:System....
SettingElement()
Initializes a new instance of the T:System.Configuration.SettingElement class.
override int GetHashCode()
Gets a unique value representing the T:System.Configuration.SettingElement current instance.
Contains the XML representing the serialized value of the setting. This class cannot be inherited.
SettingsSerializeAs SerializeAs
Gets or sets the serialization mechanism used to persist the values of the T:System....
override int GetHashCode()
Gets a unique value representing the T:System.Configuration.SettingValueElement current instance.
Represents a simplified configuration element used for updating elements in the configuration....
SettingsSerializeAs
Determines the serialization scheme used to store application settings.
SettingElement(string name, SettingsSerializeAs serializeAs)
Initializes a new instance of the T:System.Configuration.SettingElement class based on supplied param...
override bool Equals(object settings)
Compares the current T:System.Configuration.SettingElement instance to the specified object.