mscorlib(4.0.0.0) API with additions
SettingValueElement.cs
1 using System.Xml;
2 
3 namespace System.Configuration
4 {
6  public sealed class SettingValueElement : ConfigurationElement
7  {
8  private static volatile ConfigurationPropertyCollection _properties;
9 
10  private static XmlDocument doc = new XmlDocument();
11 
12  private XmlNode _valueXml;
13 
14  private bool isModified;
15 
16  protected internal override ConfigurationPropertyCollection Properties
17  {
18  protected get
19  {
20  if (_properties == null)
21  {
22  _properties = new ConfigurationPropertyCollection();
23  }
24  return _properties;
25  }
26  }
27 
30  public XmlNode ValueXml
31  {
32  get
33  {
34  return _valueXml;
35  }
36  set
37  {
38  _valueXml = value;
39  isModified = true;
40  }
41  }
42 
43  protected override void DeserializeElement(XmlReader reader, bool serializeCollectionKey)
44  {
45  ValueXml = doc.ReadNode(reader);
46  }
47 
52  public override bool Equals(object settingValue)
53  {
54  SettingValueElement settingValueElement = settingValue as SettingValueElement;
55  if (settingValueElement != null)
56  {
57  return object.Equals(settingValueElement.ValueXml, ValueXml);
58  }
59  return false;
60  }
61 
64  public override int GetHashCode()
65  {
66  return ValueXml.GetHashCode();
67  }
68 
69  protected override bool IsModified()
70  {
71  return isModified;
72  }
73 
74  protected override void ResetModified()
75  {
76  isModified = false;
77  }
78 
79  protected override bool SerializeToXmlElement(XmlWriter writer, string elementName)
80  {
81  if (ValueXml != null)
82  {
83  if (writer != null)
84  {
85  ValueXml.WriteTo(writer);
86  }
87  return true;
88  }
89  return false;
90  }
91 
92  protected override void Reset(ConfigurationElement parentElement)
93  {
94  base.Reset(parentElement);
95  ValueXml = ((SettingValueElement)parentElement).ValueXml;
96  }
97 
98  protected override void Unmerge(ConfigurationElement sourceElement, ConfigurationElement parentElement, ConfigurationSaveMode saveMode)
99  {
100  base.Unmerge(sourceElement, parentElement, saveMode);
101  ValueXml = ((SettingValueElement)sourceElement).ValueXml;
102  }
103  }
104 }
Represents an XML document. You can use this class to load, validate, edit, add, and position XML in ...
Definition: XmlDocument.cs:13
abstract void WriteTo(XmlWriter w)
Saves the current node to the specified T:System.Xml.XmlWriter, when overridden in a derived class.
Definition: __Canon.cs:3
virtual XmlNode ReadNode(XmlReader reader)
Creates an T:System.Xml.XmlNode object based on the information in the T:System.Xml....
XmlNode ValueXml
Gets or sets the value of a T:System.Configuration.SettingValueElement object by using an T:System....
Represents a writer that provides a fast, non-cached, forward-only way to generate streams or files t...
Definition: XmlWriter.cs:12
Represents a reader that provides fast, noncached, forward-only access to XML data....
Definition: XmlReader.cs:15
override bool Equals(object settingValue)
Compares the current T:System.Configuration.SettingValueElement instance to the specified object.
Contains the XML representing the serialized value of the setting. This class cannot be inherited.
override int GetHashCode()
Gets a unique value representing the T:System.Configuration.SettingValueElement current instance.
Represents a single node in the XML document.
Definition: XmlNode.cs:13