Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ChangeType() [8/9]

override object System.Xml.Schema.XmlAnyConverter.ChangeType ( object value,
Type destinationType,
IXmlNamespaceResolver nsResolver )
inline

Definition at line 251 of file XmlAnyConverter.cs.

252 {
253 if (value == null)
254 {
255 throw new ArgumentNullException("value");
256 }
257 if (destinationType == null)
258 {
259 throw new ArgumentNullException("destinationType");
260 }
261 Type type = value.GetType();
262 if (destinationType == XmlBaseConverter.ObjectType)
263 {
264 destinationType = base.DefaultClrType;
265 }
266 if (destinationType == XmlBaseConverter.BooleanType && type == XmlBaseConverter.XmlAtomicValueType)
267 {
268 return ((XmlAtomicValue)value).ValueAsBoolean;
269 }
270 if (destinationType == XmlBaseConverter.DateTimeType && type == XmlBaseConverter.XmlAtomicValueType)
271 {
272 return ((XmlAtomicValue)value).ValueAsDateTime;
273 }
274 if (destinationType == XmlBaseConverter.DateTimeOffsetType && type == XmlBaseConverter.XmlAtomicValueType)
275 {
276 return ((XmlAtomicValue)value).ValueAs(XmlBaseConverter.DateTimeOffsetType);
277 }
278 if (destinationType == XmlBaseConverter.DecimalType && type == XmlBaseConverter.XmlAtomicValueType)
279 {
280 return (decimal)((XmlAtomicValue)value).ValueAs(XmlBaseConverter.DecimalType);
281 }
282 if (destinationType == XmlBaseConverter.DoubleType && type == XmlBaseConverter.XmlAtomicValueType)
283 {
284 return ((XmlAtomicValue)value).ValueAsDouble;
285 }
286 if (destinationType == XmlBaseConverter.Int32Type && type == XmlBaseConverter.XmlAtomicValueType)
287 {
288 return ((XmlAtomicValue)value).ValueAsInt;
289 }
290 if (destinationType == XmlBaseConverter.Int64Type && type == XmlBaseConverter.XmlAtomicValueType)
291 {
292 return ((XmlAtomicValue)value).ValueAsLong;
293 }
294 if (destinationType == XmlBaseConverter.SingleType && type == XmlBaseConverter.XmlAtomicValueType)
295 {
296 return (float)((XmlAtomicValue)value).ValueAs(XmlBaseConverter.SingleType);
297 }
298 if (destinationType == XmlBaseConverter.XmlAtomicValueType)
299 {
300 if (type == XmlBaseConverter.XmlAtomicValueType)
301 {
302 return (XmlAtomicValue)value;
303 }
304 if (type == XmlBaseConverter.BooleanType)
305 {
306 return new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Boolean), (bool)value);
307 }
308 if (type == XmlBaseConverter.ByteType)
309 {
310 return new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.UnsignedByte), value);
311 }
312 if (type == XmlBaseConverter.ByteArrayType)
313 {
314 return new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Base64Binary), value);
315 }
316 if (type == XmlBaseConverter.DateTimeType)
317 {
318 return new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.DateTime), (DateTime)value);
319 }
320 if (type == XmlBaseConverter.DateTimeOffsetType)
321 {
322 return new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.DateTime), (DateTimeOffset)value);
323 }
324 if (type == XmlBaseConverter.DecimalType)
325 {
326 return new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Decimal), value);
327 }
328 if (type == XmlBaseConverter.DoubleType)
329 {
330 return new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Double), (double)value);
331 }
332 if (type == XmlBaseConverter.Int16Type)
333 {
334 return new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Short), value);
335 }
336 if (type == XmlBaseConverter.Int32Type)
337 {
338 return new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Int), (int)value);
339 }
340 if (type == XmlBaseConverter.Int64Type)
341 {
342 return new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Long), (long)value);
343 }
344 if (type == XmlBaseConverter.SByteType)
345 {
346 return new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Byte), value);
347 }
348 if (type == XmlBaseConverter.SingleType)
349 {
350 return new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Float), value);
351 }
352 if (type == XmlBaseConverter.StringType)
353 {
354 return new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.String), (string)value);
355 }
356 if (type == XmlBaseConverter.TimeSpanType)
357 {
358 return new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Duration), value);
359 }
360 if (type == XmlBaseConverter.UInt16Type)
361 {
362 return new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.UnsignedShort), value);
363 }
364 if (type == XmlBaseConverter.UInt32Type)
365 {
366 return new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.UnsignedInt), value);
367 }
368 if (type == XmlBaseConverter.UInt64Type)
369 {
370 return new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.UnsignedLong), value);
371 }
372 if (XmlBaseConverter.IsDerivedFrom(type, XmlBaseConverter.UriType))
373 {
374 return new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.AnyUri), value);
375 }
376 if (XmlBaseConverter.IsDerivedFrom(type, XmlBaseConverter.XmlQualifiedNameType))
377 {
378 return new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.QName), value, nsResolver);
379 }
380 }
381 if (destinationType == XmlBaseConverter.XPathItemType)
382 {
383 if (type == XmlBaseConverter.XmlAtomicValueType)
384 {
385 return (XmlAtomicValue)value;
386 }
387 if (XmlBaseConverter.IsDerivedFrom(type, XmlBaseConverter.XPathNavigatorType))
388 {
389 return (XPathNavigator)value;
390 }
391 }
392 if (destinationType == XmlBaseConverter.XPathNavigatorType && XmlBaseConverter.IsDerivedFrom(type, XmlBaseConverter.XPathNavigatorType))
393 {
395 }
396 if (destinationType == XmlBaseConverter.XPathItemType)
397 {
398 return (XPathItem)ChangeType(value, XmlBaseConverter.XmlAtomicValueType, nsResolver);
399 }
400 if (type == XmlBaseConverter.XmlAtomicValueType)
401 {
402 return ((XmlAtomicValue)value).ValueAs(destinationType, nsResolver);
403 }
405 }
XPathNavigator ToNavigator(XPathNavigator nav)
override object ChangeType(bool value, Type destinationType)
virtual object ChangeListType(object value, Type destinationType, IXmlNamespaceResolver nsResolver)
XmlBaseConverter(XmlSchemaType schemaType)

References System.Xml.Schema.XmlBaseConverter.BooleanType, System.Xml.Schema.XmlBaseConverter.ByteArrayType, System.Xml.Schema.XmlBaseConverter.ByteType, System.Xml.Schema.XmlBaseConverter.ChangeListType(), System.Xml.Schema.XmlAnyConverter.ChangeType(), System.Xml.Schema.XmlBaseConverter.DateTimeOffsetType, System.Xml.Schema.XmlBaseConverter.DateTimeType, System.Xml.Schema.XmlBaseConverter.DecimalType, System.Xml.Dictionary, System.Xml.Schema.XmlBaseConverter.DoubleType, System.Xml.Schema.XmlSchemaType.GetBuiltInSimpleType(), System.Type.GetType(), System.Xml.Schema.XmlBaseConverter.Int16Type, System.Xml.Schema.XmlBaseConverter.Int32Type, System.Xml.Schema.XmlBaseConverter.Int64Type, System.Xml.Schema.XmlBaseConverter.IsDerivedFrom(), System.Xml.Schema.XmlBaseConverter.ObjectType, System.Xml.Schema.XmlBaseConverter.SByteType, System.Xml.Schema.XmlBaseConverter.SingleType, System.Xml.Schema.XmlBaseConverter.StringType, System.Xml.Schema.XmlBaseConverter.TimeSpanType, System.Xml.Schema.XmlAnyConverter.ToNavigator(), System.type, System.Xml.Schema.XmlBaseConverter.UInt16Type, System.Xml.Schema.XmlBaseConverter.UInt32Type, System.Xml.Schema.XmlBaseConverter.UInt64Type, System.Xml.Schema.XmlBaseConverter.UriType, System.value, System.Xml.Schema.XmlBaseConverter.XmlAtomicValueType, System.Xml.Schema.XmlBaseConverter.XmlQualifiedNameType, System.Xml.Schema.XmlBaseConverter.XPathItemType, and System.Xml.Schema.XmlBaseConverter.XPathNavigatorType.