Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XmlException.cs
Go to the documentation of this file.
5
6namespace System.Xml;
7
9[TypeForwardedFrom("System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
11{
12 private readonly string _res;
13
14 private readonly string[] _args;
15
16 private readonly int _lineNumber;
17
18 private readonly int _linePosition;
19
20 private readonly string _sourceUri;
21
22 private readonly string _message;
23
24 public int LineNumber => _lineNumber;
25
27
28 public string? SourceUri => _sourceUri;
29
30 public override string Message
31 {
32 get
33 {
34 if (_message != null)
35 {
36 return _message;
37 }
38 return base.Message;
39 }
40 }
41
42 internal string ResString => _res;
43
45 : base(info, context)
46 {
47 _res = (string)info.GetValue("res", typeof(string));
48 _args = (string[])info.GetValue("args", typeof(string[]));
49 _lineNumber = (int)info.GetValue("lineNumber", typeof(int));
50 _linePosition = (int)info.GetValue("linePosition", typeof(int));
51 _sourceUri = string.Empty;
52 string text = null;
54 while (enumerator.MoveNext())
55 {
56 SerializationEntry current = enumerator.Current;
57 string name = current.Name;
58 if (!(name == "sourceUri"))
59 {
60 if (name == "version")
61 {
62 text = (string)current.Value;
63 }
64 }
65 else
66 {
67 _sourceUri = (string)current.Value;
68 }
69 }
70 if (text == null)
71 {
73 }
74 else
75 {
76 _message = null;
77 }
78 }
79
81 {
82 base.GetObjectData(info, context);
83 info.AddValue("res", _res);
84 info.AddValue("args", _args);
85 info.AddValue("lineNumber", _lineNumber);
86 info.AddValue("linePosition", _linePosition);
87 info.AddValue("sourceUri", _sourceUri);
88 info.AddValue("version", "2.0");
89 }
90
91 public XmlException()
92 : this(null)
93 {
94 }
95
96 public XmlException(string? message)
97 : this(message, (Exception?)null, 0, 0)
98 {
99 }
100
101 public XmlException(string? message, Exception? innerException)
102 : this(message, innerException, 0, 0)
103 {
104 }
105
106 public XmlException(string? message, Exception? innerException, int lineNumber, int linePosition)
107 : this(message, innerException, lineNumber, linePosition, null)
108 {
109 }
110
111 internal XmlException(string message, Exception innerException, int lineNumber, int linePosition, string sourceUri)
112 : base(FormatUserMessage(message, lineNumber, linePosition), innerException)
113 {
114 base.HResult = -2146232000;
115 _res = ((message == null) ? System.SR.Xml_DefaultException : System.SR.Xml_UserException);
116 _args = new string[1] { message };
118 _lineNumber = lineNumber;
119 _linePosition = linePosition;
120 }
121
122 internal XmlException(string res, string[] args)
123 : this(res, args, null, 0, 0, null)
124 {
125 }
126
127 internal XmlException(string res, string arg)
128 : this(res, new string[1] { arg }, null, 0, 0, null)
129 {
130 }
131
132 internal XmlException(string res, string arg, string sourceUri)
133 : this(res, new string[1] { arg }, null, 0, 0, sourceUri)
134 {
135 }
136
137 internal XmlException(string res, string arg, IXmlLineInfo lineInfo)
138 : this(res, new string[1] { arg }, lineInfo, null)
139 {
140 }
141
142 internal XmlException(string res, string arg, Exception innerException, IXmlLineInfo lineInfo)
143 : this(res, new string[1] { arg }, innerException, lineInfo?.LineNumber ?? 0, lineInfo?.LinePosition ?? 0, null)
144 {
145 }
146
147 internal XmlException(string res, string[] args, IXmlLineInfo lineInfo)
148 : this(res, args, lineInfo, null)
149 {
150 }
151
152 internal XmlException(string res, string[] args, IXmlLineInfo lineInfo, string sourceUri)
153 : this(res, args, null, lineInfo?.LineNumber ?? 0, lineInfo?.LinePosition ?? 0, sourceUri)
154 {
155 }
156
157 internal XmlException(string res, string arg, int lineNumber, int linePosition)
158 : this(res, new string[1] { arg }, null, lineNumber, linePosition, null)
159 {
160 }
161
162 internal XmlException(string res, string arg, int lineNumber, int linePosition, string sourceUri)
163 : this(res, new string[1] { arg }, null, lineNumber, linePosition, sourceUri)
164 {
165 }
166
167 internal XmlException(string res, string[] args, int lineNumber, int linePosition)
168 : this(res, args, null, lineNumber, linePosition, null)
169 {
170 }
171
172 internal XmlException(string res, string[] args, int lineNumber, int linePosition, string sourceUri)
173 : this(res, args, null, lineNumber, linePosition, sourceUri)
174 {
175 }
176
177 internal XmlException(string res, string[] args, Exception innerException, int lineNumber, int linePosition)
178 : this(res, args, innerException, lineNumber, linePosition, null)
179 {
180 }
181
182 internal XmlException(string res, string[] args, Exception innerException, int lineNumber, int linePosition, string sourceUri)
183 : base(CreateMessage(res, args, lineNumber, linePosition), innerException)
184 {
185 base.HResult = -2146232000;
186 _res = res;
187 _args = args;
189 _lineNumber = lineNumber;
190 _linePosition = linePosition;
191 }
192
193 private static string FormatUserMessage(string message, int lineNumber, int linePosition)
194 {
195 if (message == null)
196 {
197 return CreateMessage(System.SR.Xml_DefaultException, null, lineNumber, linePosition);
198 }
199 if (lineNumber == 0 && linePosition == 0)
200 {
201 return message;
202 }
203 return CreateMessage(System.SR.Xml_UserException, new string[1] { message }, lineNumber, linePosition);
204 }
205
206 private static string CreateMessage(string res, string[] args, int lineNumber, int linePosition)
207 {
208 try
209 {
210 string text;
211 if (args != null)
212 {
213 object[] args2 = args;
214 text = string.Format(res, args2);
215 }
216 else
217 {
218 text = res;
219 }
220 string text2 = text;
221 if (lineNumber != 0)
222 {
223 string text3 = lineNumber.ToString(CultureInfo.InvariantCulture);
224 string text4 = linePosition.ToString(CultureInfo.InvariantCulture);
226 object[] args2 = new string[3] { text2, text3, text4 };
228 }
229 return text2;
230 }
232 {
233 return "UNKNOWN(" + res + ")";
234 }
235 }
236
237 internal static string[] BuildCharExceptionArgs(string data, int invCharIndex)
238 {
239 return BuildCharExceptionArgs(data[invCharIndex], (invCharIndex + 1 < data.Length) ? data[invCharIndex + 1] : '\0');
240 }
241
242 internal static string[] BuildCharExceptionArgs(char[] data, int length, int invCharIndex)
243 {
244 return BuildCharExceptionArgs(data[invCharIndex], (invCharIndex + 1 < length) ? data[invCharIndex + 1] : '\0');
245 }
246
247 internal static string[] BuildCharExceptionArgs(char invChar, char nextChar)
248 {
249 string[] array = new string[2];
251 {
253 string[] array2 = array;
255 array2[0] = new string(span);
256 array[1] = $"0x{value:X2}";
257 }
258 else
259 {
260 if (invChar == '\0')
261 {
262 array[0] = ".";
263 }
264 else
265 {
266 array[0] = invChar.ToString();
267 }
268 array[1] = $"0x{invChar:X2}";
269 }
270 return array;
271 }
272
273 internal static bool IsCatchableException(Exception e)
274 {
275 if (!(e is OutOfMemoryException))
276 {
277 return !(e is NullReferenceException);
278 }
279 return false;
280 }
281}
static CultureInfo InvariantCulture
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string Xml_MessageWithErrorPosition
Definition SR.cs:60
static string Xml_DefaultException
Definition SR.cs:16
static string Xml_UserException
Definition SR.cs:14
Definition SR.cs:7
static int CombineSurrogateChar(int lowChar, int highChar)
static bool IsHighSurrogate(int ch)
static string[] BuildCharExceptionArgs(char[] data, int length, int invCharIndex)
static string[] BuildCharExceptionArgs(string data, int invCharIndex)
XmlException(string res, string[] args, IXmlLineInfo lineInfo)
XmlException(string res, string[] args, int lineNumber, int linePosition, string sourceUri)
XmlException(string res, string arg, Exception innerException, IXmlLineInfo lineInfo)
XmlException(string res, string[] args)
readonly string _res
XmlException(string message, Exception innerException, int lineNumber, int linePosition, string sourceUri)
XmlException(SerializationInfo info, StreamingContext context)
XmlException(string res, string arg, int lineNumber, int linePosition)
XmlException(string? message, Exception? innerException)
XmlException(string res, string[] args, Exception innerException, int lineNumber, int linePosition, string sourceUri)
readonly int _linePosition
XmlException(string res, string[] args, int lineNumber, int linePosition)
static string CreateMessage(string res, string[] args, int lineNumber, int linePosition)
XmlException(string res, string arg, IXmlLineInfo lineInfo)
override string Message
readonly string _message
XmlException(string res, string arg, int lineNumber, int linePosition, string sourceUri)
XmlException(string res, string arg)
override void GetObjectData(SerializationInfo info, StreamingContext context)
XmlException(string res, string[] args, IXmlLineInfo lineInfo, string sourceUri)
static bool IsCatchableException(Exception e)
readonly string[] _args
static string[] BuildCharExceptionArgs(char invChar, char nextChar)
XmlException(string res, string arg, string sourceUri)
XmlException(string? message)
readonly string _sourceUri
XmlException(string res, string[] args, Exception innerException, int lineNumber, int linePosition)
XmlException(string? message, Exception? innerException, int lineNumber, int linePosition)
static string FormatUserMessage(string message, int lineNumber, int linePosition)