(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / System / System.Configuration / ConfigurationException.cs
blob2c930b7d71fd86bffb24dbaf3c0bb6055e1a1561
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 string bareMessage;
46 string filename;
47 int line;
50 // Constructors
52 public ConfigurationException ()
53 : base (Locale.GetText ("There is an error in a configuration setting."))
55 filename = null;
56 bareMessage = Locale.GetText ("There is an error in a configuration setting.");
57 line = 0;
60 public ConfigurationException (string message)
61 : base (message)
63 bareMessage = message;
66 protected ConfigurationException (SerializationInfo info, StreamingContext context)
67 : base (info, context)
69 filename = info.GetString ("filename");
70 line = info.GetInt32 ("line");
73 public ConfigurationException (string message, Exception inner)
74 : base (message, inner)
76 bareMessage = message;
79 #if (XML_DEP)
80 public ConfigurationException (string message, XmlNode node)
81 : base (message)
83 filename = GetXmlNodeFilename(node);
84 line = GetXmlNodeLineNumber(node);
85 bareMessage = message;
88 public ConfigurationException (string message, Exception inner, XmlNode node)
89 : base (message, inner)
91 filename = GetXmlNodeFilename (node);
92 line = GetXmlNodeLineNumber (node);
93 bareMessage = message;
95 #endif
96 public ConfigurationException (string message, string filename, int line)
97 : base (message)
99 bareMessage = message;
100 this.filename = filename;
101 this.line= line;
104 public ConfigurationException (string message, Exception inner, string filename, int line)
105 : base (message)
107 bareMessage = message;
108 this.filename = filename;
109 this.line = line;
112 // Properties
114 public string BareMessage
116 get { return bareMessage; }
119 public string Filename
121 get { return filename; }
124 public int Line
126 get { return line; }
129 public override string Message
131 get {
132 string baseMsg = base.Message;
133 string f = (filename == null) ? String.Empty : filename;
134 string l = (line == 0) ? String.Empty : (" line " + line);
136 return baseMsg + " (" + f + l + ")";
141 // Methods
143 #if (XML_DEP)
144 public static string GetXmlNodeFilename (XmlNode node)
146 if (!(node is IConfigXmlNode))
147 return String.Empty;
149 return ((IConfigXmlNode) node).Filename;
152 public static int GetXmlNodeLineNumber (XmlNode node)
154 if (!(node is IConfigXmlNode))
155 return 0;
157 return ((IConfigXmlNode) node).LineNumber;
159 #endif
160 public override void GetObjectData (SerializationInfo info, StreamingContext context)
162 base.GetObjectData (info, context);
163 info.AddValue ("filename", filename);
164 info.AddValue ("line", line);