Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XmlUntypedStringConverter.cs
Go to the documentation of this file.
1namespace System.Xml.Schema;
2
3internal sealed class XmlUntypedStringConverter
4{
5 private readonly bool _listsAllowed;
6
8
9 private static readonly Type s_decimalType = typeof(decimal);
10
11 private static readonly Type s_int32Type = typeof(int);
12
13 private static readonly Type s_int64Type = typeof(long);
14
15 private static readonly Type s_stringType = typeof(string);
16
17 private static readonly Type s_objectType = typeof(object);
18
19 private static readonly Type s_byteType = typeof(byte);
20
21 private static readonly Type s_int16Type = typeof(short);
22
23 private static readonly Type s_SByteType = typeof(sbyte);
24
25 private static readonly Type s_UInt16Type = typeof(ushort);
26
27 private static readonly Type s_UInt32Type = typeof(uint);
28
29 private static readonly Type s_UInt64Type = typeof(ulong);
30
31 private static readonly Type s_doubleType = typeof(double);
32
33 private static readonly Type s_singleType = typeof(float);
34
35 private static readonly Type s_dateTimeType = typeof(DateTime);
36
37 private static readonly Type s_dateTimeOffsetType = typeof(DateTimeOffset);
38
39 private static readonly Type s_booleanType = typeof(bool);
40
41 private static readonly Type s_byteArrayType = typeof(byte[]);
42
44
45 private static readonly Type s_uriType = typeof(Uri);
46
47 private static readonly Type s_timeSpanType = typeof(TimeSpan);
48
50
59
61 {
62 if (value == null)
63 {
64 throw new ArgumentNullException("value");
65 }
66 if (destinationType == null)
67 {
68 throw new ArgumentNullException("destinationType");
69 }
71 {
72 destinationType = typeof(string);
73 }
75 {
77 }
79 {
81 }
83 {
85 }
87 {
88 return StringToDateTime(value);
89 }
91 {
93 }
95 {
97 }
99 {
100 return XmlConvert.ToDouble(value);
101 }
103 {
105 }
107 {
108 return XmlConvert.ToInt32(value);
109 }
111 {
112 return XmlConvert.ToInt64(value);
113 }
115 {
117 }
119 {
120 return XmlConvert.ToSingle(value);
121 }
123 {
124 return StringToDuration(value);
125 }
127 {
129 }
131 {
133 }
135 {
137 }
139 {
140 return XmlConvert.ToUri(value);
141 }
143 {
145 }
147 {
148 return value;
149 }
151 }
152
153 private byte Int32ToByte(int value)
154 {
155 if (value < 0 || value > 255)
156 {
158 object[] args = new string[2]
159 {
161 "Byte"
162 };
164 }
165 return (byte)value;
166 }
167
168 private short Int32ToInt16(int value)
169 {
171 {
173 object[] args = new string[2]
174 {
176 "Int16"
177 };
179 }
180 return (short)value;
181 }
182
183 private sbyte Int32ToSByte(int value)
184 {
186 {
188 object[] args = new string[2]
189 {
191 "SByte"
192 };
194 }
195 return (sbyte)value;
196 }
197
198 private ushort Int32ToUInt16(int value)
199 {
200 if (value < 0 || value > 65535)
201 {
203 object[] args = new string[2]
204 {
206 "UInt16"
207 };
209 }
210 return (ushort)value;
211 }
212
213 private uint Int64ToUInt32(long value)
214 {
215 if (value < 0 || value > uint.MaxValue)
216 {
218 object[] args = new string[2]
219 {
221 "UInt32"
222 };
224 }
225 return (uint)value;
226 }
227
228 private ulong DecimalToUInt64(decimal value)
229 {
230 if (value < 0m || value > 18446744073709551615m)
231 {
233 object[] args = new string[2]
234 {
236 "UInt64"
237 };
239 }
240 return (ulong)value;
241 }
242
243 private byte[] StringToBase64Binary(string value)
244 {
246 }
247
248 private static DateTime StringToDateTime(string value)
249 {
250 return new XsdDateTime(value, XsdDateTimeFlags.AllXsd);
251 }
252
254 {
255 return new XsdDateTime(value, XsdDateTimeFlags.AllXsd);
256 }
257
259 {
261 }
262
264 {
265 value = value.Trim();
266 string prefix;
267 string localName;
268 try
269 {
271 }
272 catch (XmlException ex)
273 {
274 throw new FormatException(ex.Message);
275 }
276 if (nsResolver == null)
277 {
279 }
280 string text = nsResolver.LookupNamespace(prefix);
281 if (text == null)
282 {
284 }
285 return new XmlQualifiedName(localName, text);
286 }
287
289 {
290 if (_listsAllowed && destinationType.IsArray)
291 {
294 {
296 }
298 {
300 }
301 if (elementType == s_byteType)
302 {
304 }
306 {
308 }
310 {
312 }
314 {
316 }
318 {
320 }
322 {
324 }
326 {
328 }
330 {
332 }
334 {
336 }
338 {
340 }
342 {
344 }
346 {
348 }
350 {
352 }
354 {
356 }
358 {
360 }
362 {
364 }
365 if (elementType == s_uriType)
366 {
368 }
370 {
372 }
373 }
375 }
376
378 {
379 T[] array = new T[stringArray.Length];
380 for (int i = 0; i < stringArray.Length; i++)
381 {
383 }
384 return array;
385 }
386
391}
static unsafe byte[] FromBase64String(string s)
Definition Convert.cs:2904
static string XmlConvert_Overflow
Definition SR.cs:372
static string XmlConvert_TypeListBadMapping2
Definition SR.cs:380
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string XmlConvert_TypeNoNamespace
Definition SR.cs:388
Definition SR.cs:7
Type? GetElementType()
static XmlQualifiedName StringToQName(string value, IXmlNamespaceResolver nsResolver)
T[] ToArray< T >(string[] stringArray, IXmlNamespaceResolver nsResolver)
Exception CreateInvalidClrMappingException(Type sourceType, Type destinationType)
object FromString(string value, Type destinationType, IXmlNamespaceResolver nsResolver)
static DateTimeOffset StringToDateTimeOffset(string value)
readonly XmlUntypedStringConverter _listItemConverter
object StringToListType(string value, Type destinationType, IXmlNamespaceResolver nsResolver)
static int ParseQNameThrow(string s)
static bool ToBoolean(string s)
static string[] SplitString(string value)
static int ToInt32(string s)
static string ToString(bool value)
static string TrimString(string value)
static float ToSingle(string s)
static double ToDouble(string s)
static Uri ToUri(string s)
static decimal ToDecimal(string s)
static long ToInt64(string s)