2 // System.Xml.XmlCharacterData.cs
5 // Jason Diamond <jason@injektilo.org>
6 // Kral Ferch <kral_ferch@hotmail.com>
8 // (C) 2002 Jason Diamond, Kral Ferch
15 public abstract class XmlCharacterData : XmlLinkedNode
21 protected internal XmlCharacterData (string data, XmlDocument doc)
34 public virtual string Data {
40 public override string InnerText {
46 public virtual int Length {
47 get { return data != null ? data.Length : 0; }
50 public override string Value {
54 OwnerDocument.onNodeChanging (this, this.ParentNode);
57 throw new ArgumentException ("Node is read-only.");
61 OwnerDocument.onNodeChanged (this, this.ParentNode);
69 public virtual void AppendData (string strData)
71 OwnerDocument.onNodeChanging (this, this.ParentNode);
73 OwnerDocument.onNodeChanged (this, this.ParentNode);
76 public virtual void DeleteData (int offset, int count)
78 OwnerDocument.onNodeChanging (this, this.ParentNode);
81 throw new ArgumentOutOfRangeException ("offset", "Must be non-negative and must not be greater than the length of this instance.");
83 int newCount = data.Length - offset;
85 if ((offset + count) < data.Length)
88 data = data.Remove (offset, newCount);
90 OwnerDocument.onNodeChanged (this, this.ParentNode);
93 public virtual void InsertData (int offset, string strData)
95 OwnerDocument.onNodeChanging (this, this.ParentNode);
97 if ((offset < 0) || (offset > data.Length))
98 throw new ArgumentOutOfRangeException ("offset", "Must be non-negative and must not be greater than the length of this instance.");
100 data = data.Insert(offset, strData);
102 OwnerDocument.onNodeChanged (this, this.ParentNode);
105 public virtual void ReplaceData (int offset, int count, string strData)
107 OwnerDocument.onNodeChanging (this, this.ParentNode);
109 if ((offset < 0) || (offset > data.Length))
110 throw new ArgumentOutOfRangeException ("offset", "Must be non-negative and must not be greater than the length of this instance.");
113 throw new ArgumentNullException ("strData", "Must be non-null.");
115 string newData = data.Substring (0, offset) + strData;
117 if ((offset + count) < data.Length)
118 newData += data.Substring (offset + count);
122 OwnerDocument.onNodeChanged (this, this.ParentNode);
125 public virtual string Substring (int offset, int count)
127 return data.Substring (offset, count);