[System] remove unused file
[mono-project.git] / mcs / class / System / System.Configuration / ConfigurationException.cs
blob6f36e97bc08c90dac72baa4e36a8e9a3b0c53ed6
1 //
2 // System.Configuration.ConfigurationException.cs
3 //
4 // Author:
5 // Duncan Mak (duncan@ximian.com)
6 //
7 // (C) Ximian, Inc. http://www.ximian.com
8 //
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.
31 using System;
32 using System.Globalization;
33 using System.Runtime.Serialization;
35 #if (XML_DEP)
36 using System.Xml;
37 #endif
39 namespace System.Configuration
41 [Serializable]
42 public class ConfigurationException : SystemException
44 // Fields
45 readonly string filename;
46 readonly int line;
49 // Constructors
51 [Obsolete ("This class is obsolete. Use System.Configuration.ConfigurationErrorsException")]
52 public ConfigurationException () : this (null)
54 filename = null;
55 line = 0;
58 [Obsolete ("This class is obsolete. Use System.Configuration.ConfigurationErrorsException")]
59 public ConfigurationException (string message)
60 : base (message)
64 protected ConfigurationException (SerializationInfo info, StreamingContext context)
65 : base (info, context)
67 filename = info.GetString ("filename");
68 line = info.GetInt32 ("line");
71 [Obsolete ("This class is obsolete. Use System.Configuration.ConfigurationErrorsException")]
72 public ConfigurationException (string message, Exception inner)
73 : base (message, inner)
77 #if (XML_DEP)
78 [Obsolete ("This class is obsolete. Use System.Configuration.ConfigurationErrorsException")]
79 public ConfigurationException (string message, XmlNode node)
80 : base (message)
82 filename = GetXmlNodeFilename(node);
83 line = GetXmlNodeLineNumber(node);
86 [Obsolete ("This class is obsolete. Use System.Configuration.ConfigurationErrorsException")]
87 public ConfigurationException (string message, Exception inner, XmlNode node)
88 : base (message, inner)
90 filename = GetXmlNodeFilename (node);
91 line = GetXmlNodeLineNumber (node);
93 #endif
94 [Obsolete ("This class is obsolete. Use System.Configuration.ConfigurationErrorsException")]
95 public ConfigurationException (string message, string filename, int line)
96 : base (message)
98 this.filename = filename;
99 this.line= line;
102 [Obsolete ("This class is obsolete. Use System.Configuration.ConfigurationErrorsException")]
103 public ConfigurationException (string message, Exception inner, string filename, int line)
104 : base (message, inner)
106 this.filename = filename;
107 this.line = line;
110 // Properties
112 public virtual string BareMessage {
113 get { return base.Message; }
116 public virtual string Filename {
117 get { return filename; }
120 public virtual int Line {
121 get { return line; }
124 public override string Message {
125 get {
126 string msg;
127 if (filename != null && filename.Length != 0) {
128 if (line != 0)
129 msg = BareMessage + " (" + filename + " line " + line + ")";
130 else
131 msg = BareMessage + " (" + filename + ")";
132 } else {
133 if (line != 0)
134 msg = BareMessage + " (line " + line + ")";
135 else
136 msg = BareMessage;
138 return msg;
143 // Methods
145 #if (XML_DEP)
146 [Obsolete ("This class is obsolete. Use System.Configuration.ConfigurationErrorsException")]
147 public static string GetXmlNodeFilename (XmlNode node)
149 if (!(node is IConfigXmlNode))
150 return String.Empty;
152 return ((IConfigXmlNode) node).Filename;
155 [Obsolete ("This class is obsolete. Use System.Configuration.ConfigurationErrorsException")]
156 public static int GetXmlNodeLineNumber (XmlNode node)
158 if (!(node is IConfigXmlNode))
159 return 0;
161 return ((IConfigXmlNode) node).LineNumber;
163 #endif
164 public override void GetObjectData (SerializationInfo info, StreamingContext context)
166 base.GetObjectData (info, context);
167 info.AddValue ("filename", filename);
168 info.AddValue ("line", line);