(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / System.XML / System.Xml / XmlException.cs
blob5a5b62125245c7b13a07345ff3d1f60425297179
1 //
2 // XmlException.cs
3 //
4 // Author:
5 // Jason Diamond (jason@injektilo.org)
6 // Atsushi Enomoto (atsushi@ximian.com)
7 //
8 // (C) 2002 Jason Diamond http://injektilo.org/
9 // (C) 2004 Novell Inc.
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 using System;
34 using System.Globalization;
35 using System.Runtime.Serialization;
37 namespace System.Xml
39 [Serializable]
40 public class XmlException : SystemException
42 #region Fields
44 int lineNumber;
45 int linePosition;
46 string sourceUri;
48 #endregion
50 #region Constructors
52 #if NET_1_0
53 #else
54 public XmlException ()
55 : base ()
58 #endif
59 public XmlException (string message, Exception innerException)
60 : base (message, innerException)
64 protected XmlException (SerializationInfo info, StreamingContext context)
65 : base (info, context)
67 this.lineNumber = info.GetInt32 ("lineNumber");
68 this.linePosition = info.GetInt32 ("linePosition");
69 this.sourceUri = info.GetString ("sourceUri");
72 #if NET_1_0
73 internal XmlException (string message)
74 #else
75 public XmlException (string message)
76 #endif
77 : base (message)
81 internal XmlException (IXmlLineInfo li, string sourceUri, string message) : base (message)
83 if (li != null) {
84 this.lineNumber = li.LineNumber;
85 this.linePosition = li.LinePosition;
87 this.sourceUri = sourceUri;
90 #if NET_1_0
91 internal XmlException (string message, Exception innerException, int lineNumber, int linePosition)
92 #else
93 public XmlException (string message, Exception innerException, int lineNumber, int linePosition)
94 #endif
95 : base (message, innerException)
97 this.lineNumber = lineNumber;
98 this.linePosition = linePosition;
101 #endregion
103 #region Properties
105 public int LineNumber {
106 get { return lineNumber; }
109 public int LinePosition {
110 get { return linePosition; }
113 #if NET_2_0
114 public string SourceUri {
115 get { return sourceUri; }
117 #endif
119 public override string Message {
120 get {
121 if (lineNumber == 0)
122 return base.Message;
124 return String.Format (CultureInfo.InvariantCulture, "{0} {3} Line {1}, position {2}.",
125 base.Message, lineNumber, linePosition, sourceUri);
129 #endregion
131 #region Methods
133 public override void GetObjectData (SerializationInfo info, StreamingContext context)
135 base.GetObjectData (info, context);
136 info.AddValue ("lineNumber", lineNumber);
137 info.AddValue ("linePosition", linePosition);
138 info.AddValue ("sourceUri", sourceUri);
141 #endregion