BindingFlags.Public needed here as Exception.HResult is now public in .NET 4.5. This...
[mono.git] / mcs / class / System.XML / System.Xml / XmlText.cs
1 //
2 // System.Xml.XmlText
3 //
4 // Author:
5 //   Jason Diamond <jason@injektilo.org>
6 //
7 // (C) 2002 Jason Diamond  http://injektilo.org/
8 //
9
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30
31 using System;
32 using System.Xml.XPath;
33
34 namespace System.Xml
35 {
36         public class XmlText : XmlCharacterData
37         {
38                 #region Constructor
39
40                 protected internal XmlText (string strData, XmlDocument doc) : base(strData, doc)
41                 {
42                 }
43
44                 #endregion
45
46                 #region Properties
47
48                 public override string LocalName 
49                 {
50                         get { return "#text"; }
51                 }
52
53                 public override string Name {
54                         get { return "#text"; }
55                 }
56
57                 public override XmlNodeType NodeType {
58                         get { return XmlNodeType.Text; }
59                 }
60
61                 internal override XPathNodeType XPathNodeType {
62                         get {
63                                 return XPathNodeType.Text;
64                         }
65                 }
66                 
67                 public override string Value {
68                         get { return Data; }
69                         set { Data = value; }
70                 }
71
72 #if NET_2_0
73                 public override XmlNode ParentNode {
74                         get { return base.ParentNode; }
75                 }
76 #endif
77                 #endregion
78
79                 #region Methods
80
81                 public override XmlNode CloneNode (bool deep)
82                 {
83                         XmlText newText = OwnerDocument.CreateTextNode(Data);
84                         return newText;
85                 }
86
87                 public virtual XmlText SplitText (int offset)
88                 {
89                         XmlText next = OwnerDocument.CreateTextNode (this.Data.Substring (offset));
90                         DeleteData (offset, Data.Length - offset);
91                         this.ParentNode.InsertAfter (next, this);
92                         return next;
93                 }
94
95                 public override void WriteContentTo (XmlWriter w) {}
96
97                 public override void WriteTo (XmlWriter w)
98                 {
99                         w.WriteString (Data);
100                 }
101
102                 #endregion
103         }
104 }