mscorlib(4.0.0.0) API with additions
XmlSchemaException.cs
1 using System.Resources;
4 
5 namespace System.Xml.Schema
6 {
10  {
11  private string res;
12 
13  private string[] args;
14 
15  private string sourceUri;
16 
17  private int lineNumber;
18 
19  private int linePosition;
20 
21  [NonSerialized]
22  private XmlSchemaObject sourceSchemaObject;
23 
24  private string message;
25 
26  internal string GetRes => res;
27 
28  internal string[] Args => args;
29 
32  public string SourceUri => sourceUri;
33 
36  public int LineNumber => lineNumber;
37 
40  public int LinePosition => linePosition;
41 
44  public XmlSchemaObject SourceSchemaObject => sourceSchemaObject;
45 
48  public override string Message
49  {
50  get
51  {
52  if (message != null)
53  {
54  return message;
55  }
56  return base.Message;
57  }
58  }
59 
64  : base(info, context)
65  {
66  res = (string)info.GetValue("res", typeof(string));
67  args = (string[])info.GetValue("args", typeof(string[]));
68  sourceUri = (string)info.GetValue("sourceUri", typeof(string));
69  lineNumber = (int)info.GetValue("lineNumber", typeof(int));
70  linePosition = (int)info.GetValue("linePosition", typeof(int));
71  string text = null;
72  SerializationInfoEnumerator enumerator = info.GetEnumerator();
73  while (enumerator.MoveNext())
74  {
75  SerializationEntry current = enumerator.Current;
76  if (current.Name == "version")
77  {
78  text = (string)current.Value;
79  }
80  }
81  if (text == null)
82  {
83  message = CreateMessage(res, args);
84  }
85  else
86  {
87  message = null;
88  }
89  }
90 
94  [SecurityPermission(SecurityAction.LinkDemand, SerializationFormatter = true)]
95  public override void GetObjectData(SerializationInfo info, StreamingContext context)
96  {
97  base.GetObjectData(info, context);
98  info.AddValue("res", res);
99  info.AddValue("args", args);
100  info.AddValue("sourceUri", sourceUri);
101  info.AddValue("lineNumber", lineNumber);
102  info.AddValue("linePosition", linePosition);
103  info.AddValue("version", "2.0");
104  }
105 
108  : this(null)
109  {
110  }
111 
114  public XmlSchemaException(string message)
115  : this(message, (Exception)null, 0, 0)
116  {
117  }
118 
122  public XmlSchemaException(string message, Exception innerException)
123  : this(message, innerException, 0, 0)
124  {
125  }
126 
132  public XmlSchemaException(string message, Exception innerException, int lineNumber, int linePosition)
133  : this((message == null) ? "Sch_DefaultException" : "Xml_UserException", new string[1]
134  {
135  message
136  }, innerException, null, lineNumber, linePosition, null)
137  {
138  }
139 
140  internal XmlSchemaException(string res, string[] args)
141  : this(res, args, null, null, 0, 0, null)
142  {
143  }
144 
145  internal XmlSchemaException(string res, string arg)
146  : this(res, new string[1]
147  {
148  arg
149  }, null, null, 0, 0, null)
150  {
151  }
152 
153  internal XmlSchemaException(string res, string arg, string sourceUri, int lineNumber, int linePosition)
154  : this(res, new string[1]
155  {
156  arg
157  }, null, sourceUri, lineNumber, linePosition, null)
158  {
159  }
160 
161  internal XmlSchemaException(string res, string sourceUri, int lineNumber, int linePosition)
162  : this(res, null, null, sourceUri, lineNumber, linePosition, null)
163  {
164  }
165 
166  internal XmlSchemaException(string res, string[] args, string sourceUri, int lineNumber, int linePosition)
167  : this(res, args, null, sourceUri, lineNumber, linePosition, null)
168  {
169  }
170 
171  internal XmlSchemaException(string res, XmlSchemaObject source)
172  : this(res, (string[])null, source)
173  {
174  }
175 
176  internal XmlSchemaException(string res, string arg, XmlSchemaObject source)
177  : this(res, new string[1]
178  {
179  arg
180  }, source)
181  {
182  }
183 
184  internal XmlSchemaException(string res, string[] args, XmlSchemaObject source)
185  : this(res, args, null, source.SourceUri, source.LineNumber, source.LinePosition, source)
186  {
187  }
188 
189  internal XmlSchemaException(string res, string[] args, Exception innerException, string sourceUri, int lineNumber, int linePosition, XmlSchemaObject source)
190  : base(CreateMessage(res, args), innerException)
191  {
192  base.HResult = -2146231999;
193  this.res = res;
194  this.args = args;
195  this.sourceUri = sourceUri;
196  this.lineNumber = lineNumber;
197  this.linePosition = linePosition;
198  sourceSchemaObject = source;
199  }
200 
201  internal static string CreateMessage(string res, string[] args)
202  {
203  try
204  {
205  return Res.GetString(res, args);
206  }
208  {
209  return "UNKNOWN(" + res + ")";
210  }
211  }
212 
213  internal void SetSource(string sourceUri, int lineNumber, int linePosition)
214  {
215  this.sourceUri = sourceUri;
216  this.lineNumber = lineNumber;
217  this.linePosition = linePosition;
218  }
219 
220  internal void SetSchemaObject(XmlSchemaObject source)
221  {
222  sourceSchemaObject = source;
223  }
224 
225  internal void SetSource(XmlSchemaObject source)
226  {
227  sourceSchemaObject = source;
228  sourceUri = source.SourceUri;
229  lineNumber = source.LineNumber;
230  linePosition = source.LinePosition;
231  }
232 
233  internal void SetResourceId(string resourceId)
234  {
235  res = resourceId;
236  }
237  }
238 }
Describes a set of security permissions applied to code. This class cannot be inherited.
XmlSchemaException()
Initializes a new instance of the T:System.Xml.Schema.XmlSchemaException class.
Serves as the base class for system exceptions namespace.
XmlSchemaException(string message)
Initializes a new instance of the T:System.Xml.Schema.XmlSchemaException class with the exception mes...
Definition: __Canon.cs:3
Represents the root class for the Xml schema object model hierarchy and serves as a base class for cl...
int LineNumber
Gets the line number indicating where the error occurred.
XmlSchemaObject SourceSchemaObject
The XmlSchemaObject that produced the XmlSchemaException.
Describes the source and destination of a given serialized stream, and provides an additional caller-...
SecurityAction
Specifies the security actions that can be performed using declarative security.
XmlSchemaException(SerializationInfo info, StreamingContext context)
Constructs a new XmlSchemaException object with the given SerializationInfo and StreamingContext info...
string SourceUri
Gets the Uniform Resource Identifier (URI) location of the schema that caused the exception.
Stores all the data needed to serialize or deserialize an object. This class cannot be inherited.
The exception that is thrown if the main assembly does not contain the resources for the neutral cult...
int LinePosition
Gets the line position indicating where the error occurred.
Exception()
Initializes a new instance of the T:System.Exception class.
Definition: Exception.cs:286
XmlSchemaException(string message, Exception innerException)
Initializes a new instance of the T:System.Xml.Schema.XmlSchemaException class with the exception mes...
Represents errors that occur during application execution.To browse the .NET Framework source code fo...
Definition: Exception.cs:22
string SourceUri
Gets or sets the source location for the file that loaded the schema.
Specifies that the class can be serialized.
override void GetObjectData(SerializationInfo info, StreamingContext context)
Streams all the XmlSchemaException properties into the SerializationInfo class for the given Streamin...
Holds the value, T:System.Type, and name of a serialized object.
Returns detailed information about the schema exception.
Provides a formatter-friendly mechanism for parsing the data in T:System.Runtime.Serialization....
object Value
Gets the value contained in the object.
string Name
Gets the name of the object.
override string Message
Gets the description of the error condition of this exception.
bool MoveNext()
Updates the enumerator to the next item.