Update mcs/class/Commons.Xml.Relaxng/Commons.Xml.Relaxng/RelaxngPattern.cs
[mono.git] / mcs / class / Microsoft.Build.Engine / Microsoft.Build.BuildEngine / InvalidProjectFileException.cs
1 //
2 // InvalidProjectFileException.cs:
3 //
4 // Author:
5 //   Marek Sieradzki (marek.sieradzki@gmail.com)
6 // 
7 // (C) 2005 Marek Sieradzki
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
28 #if NET_2_0
29
30 using System;
31 using System.Runtime.Serialization;
32 using System.Security.Permissions;
33 using System.Xml;
34
35 namespace Microsoft.Build.BuildEngine {
36         [Serializable]
37         public sealed class InvalidProjectFileException : Exception {
38                 
39                 int     columnNumber;
40                 int     endColumnNumber;
41                 string  errorCode;
42                 string  errorSubcategory;
43                 string  helpKeyword;
44                 int     lineNumber;
45                 int     endLineNumber;
46                 string  projectFile;
47                 
48                 public InvalidProjectFileException ()
49                         : base ("Invalid project file exception has occured")
50                 {
51                 }
52
53                 public InvalidProjectFileException (string message)
54                         : base (message)
55                 {
56                 }
57
58                 public InvalidProjectFileException (string projectFile,
59                                                     int lineNumber,
60                                                     int columnNumber,
61                                                     int endLineNumber,
62                                                     int endColumnNumber,
63                                                     string message,
64                                                     string errorSubcategory,
65                                                     string errorCode,
66                                                     string helpKeyword)
67                         : base (message)
68                 {
69                         this.projectFile = projectFile;
70                         this.lineNumber = lineNumber;
71                         this.columnNumber = columnNumber;
72                         this.endLineNumber = endLineNumber;
73                         this.endColumnNumber = endColumnNumber;
74                         this.errorSubcategory = errorSubcategory;
75                         this.errorCode = errorCode;
76                         this.helpKeyword = helpKeyword;
77                 }
78
79                 public InvalidProjectFileException (string message,
80                                                     Exception innerException)
81                         : base (message, innerException)
82                 {
83                 }
84
85                 // FIXME: set line/column numbers?
86                 [MonoTODO]
87                 public InvalidProjectFileException (XmlNode xmlNode,
88                                                     string message,
89                                                     string errorSubcategory,
90                                                     string errorCode,
91                                                     string helpKeyword)
92                         : base (message)
93                 {
94                         this.errorSubcategory = errorSubcategory;
95                         this.errorCode = errorCode;
96                         this.helpKeyword = helpKeyword;
97                 }
98
99                 // FIXME: private temporarily
100                 private InvalidProjectFileException (SerializationInfo info, StreamingContext context)
101                         : base (info, context)
102                 {
103                         this.columnNumber = info.GetInt32 ("columnNumber");
104                         this.endColumnNumber = info.GetInt32 ("endColumnNumber");
105                         this.errorCode = info.GetString ("errorCode");
106                         this.errorSubcategory = info.GetString ("errorSubcategory");
107                         this.helpKeyword = info.GetString ("helpKeyword");
108                         this.lineNumber = info.GetInt32 ("lineNumber");
109                         this.endLineNumber = info.GetInt32 ("endLineNumber");
110                         this.projectFile = info.GetString ("projectFile");
111                 }
112
113                 [SecurityPermission (SecurityAction.LinkDemand, SerializationFormatter = true)]
114                 public override void GetObjectData (SerializationInfo info,
115                                                     StreamingContext context)
116                 {
117                         base.GetObjectData (info, context);
118                         info.AddValue ("columnNumber", columnNumber);
119                         info.AddValue ("endColumnNumber", endColumnNumber);
120                         info.AddValue ("errorCode", errorCode);
121                         info.AddValue ("errorSubcategory", errorSubcategory);
122                         info.AddValue ("helpKeyword", helpKeyword);
123                         info.AddValue ("lineNumber", lineNumber);
124                         info.AddValue ("endLineNumber", endLineNumber);
125                         info.AddValue ("projectFile", projectFile);
126                 }
127
128                 public string BaseMessage {
129                         get {
130                                 return base.Message;
131                         }
132                 }
133
134                 public int ColumnNumber {
135                         get {
136                                 return columnNumber;
137                         }
138                 }
139
140                 public int EndColumnNumber {
141                         get {
142                                 return endColumnNumber;
143                         }
144                 }
145
146                 public int EndLineNumber {
147                         get {
148                                 return endLineNumber;
149                         }
150                 }
151
152                 public string ErrorCode {
153                         get {
154                                 return errorCode;
155                         }
156                 }
157
158                 public string ErrorSubcategory {
159                         get {
160                                 return errorSubcategory;
161                         }
162                 }
163
164                 public string HelpKeyword {
165                         get {
166                                 return helpKeyword;
167                         }
168                 }
169
170                 public int LineNumber {
171                         get {
172                                 return lineNumber;
173                         }
174                 }
175
176                 public override string Message {
177                         get {
178                                 if (projectFile == null || projectFile == String.Empty) {
179                                         return BaseMessage;
180                                 } else {
181                                         return BaseMessage + "  " + ProjectFile;
182                                 }
183                         }
184                 }
185
186                 public string ProjectFile {
187                         get {
188                                 return projectFile;
189                         }
190                 }
191         }
192 }
193
194 #endif