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 {
38 OwnerDocument.onNodeChanging (this, this.ParentNode);
41 throw new ArgumentException ("Node is read-only.");
45 OwnerDocument.onNodeChanged (this, this.ParentNode);
49 public override string InnerText {
52 set { Data = value; } // invokes events
55 public virtual int Length {
56 get { return data != null ? data.Length : 0; }
59 public override string Value {
71 public virtual void AppendData (string strData)
73 OwnerDocument.onNodeChanging (this, this.ParentNode);
75 OwnerDocument.onNodeChanged (this, this.ParentNode);
78 public virtual void DeleteData (int offset, int count)
80 OwnerDocument.onNodeChanging (this, this.ParentNode);
83 throw new ArgumentOutOfRangeException ("offset", "Must be non-negative and must not be greater than the length of this instance.");
85 int newCount = data.Length - offset;
87 if ((offset + count) < data.Length)
90 data = data.Remove (offset, newCount);
92 OwnerDocument.onNodeChanged (this, this.ParentNode);
95 public virtual void InsertData (int offset, string strData)
97 OwnerDocument.onNodeChanging (this, this.ParentNode);
99 if ((offset < 0) || (offset > data.Length))
100 throw new ArgumentOutOfRangeException ("offset", "Must be non-negative and must not be greater than the length of this instance.");
102 data = data.Insert(offset, strData);
104 OwnerDocument.onNodeChanged (this, this.ParentNode);
107 public virtual void ReplaceData (int offset, int count, string strData)
109 OwnerDocument.onNodeChanging (this, this.ParentNode);
111 if ((offset < 0) || (offset > data.Length))
112 throw new ArgumentOutOfRangeException ("offset", "Must be non-negative and must not be greater than the length of this instance.");
115 throw new ArgumentNullException ("strData", "Must be non-null.");
117 string newData = data.Substring (0, offset) + strData;
119 if ((offset + count) < data.Length)
120 newData += data.Substring (offset + count);
124 OwnerDocument.onNodeChanged (this, this.ParentNode);
127 public virtual string Substring (int offset, int count)
129 return data.Substring (offset, count);