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

◆ ConvertXmlToObject() [2/2]

override object System.Data.Common.ObjectStorage.ConvertXmlToObject ( XmlReader xmlReader,
XmlRootAttribute xmlAttrib )
inlinevirtual

Reimplemented from System.Data.Common.DataStorage.

Definition at line 411 of file ObjectStorage.cs.

412 {
413 object obj = null;
414 bool flag = false;
415 bool flag2 = false;
416 if (xmlAttrib == null)
417 {
418 Type type = null;
419 string attribute = xmlReader.GetAttribute("InstanceType", "urn:schemas-microsoft-com:xml-msdata");
420 if (attribute == null || attribute.Length == 0)
421 {
422 string text = xmlReader.GetAttribute("type", "http://www.w3.org/2001/XMLSchema-instance");
423 if (text != null && text.Length > 0)
424 {
425 string[] array = text.Split(':');
426 if (array.Length == 2 && xmlReader.LookupNamespace(array[0]) == "http://www.w3.org/2001/XMLSchema")
427 {
428 text = array[1];
429 }
430 type = XSDSchema.XsdtoClr(text);
431 flag = true;
432 }
433 else if (_dataType == typeof(object))
434 {
435 flag2 = true;
436 }
437 }
438 if (flag2)
439 {
440 obj = xmlReader.ReadString();
441 }
442 else if (attribute == "Type")
443 {
444 obj = Type.GetType(xmlReader.ReadString());
445 xmlReader.Read();
446 }
447 else
448 {
449 if (null == type)
450 {
452 }
453 if (type == typeof(char) || type == typeof(Guid))
454 {
455 flag = true;
456 }
457 if (type == typeof(object))
458 {
459 throw ExceptionBuilder.CanNotDeserializeObjectType();
460 }
461 TypeLimiter.EnsureTypeIsAllowed(type);
462 if (!flag)
463 {
464 obj = Activator.CreateInstance(type, nonPublic: true);
465 ((IXmlSerializable)obj).ReadXml(xmlReader);
466 }
467 else
468 {
469 if (type == typeof(string) && xmlReader.NodeType == XmlNodeType.Element && xmlReader.IsEmptyElement)
470 {
471 obj = string.Empty;
472 }
473 else
474 {
475 obj = xmlReader.ReadString();
476 obj = ((!(type != typeof(byte[]))) ? Convert.FromBase64String(obj.ToString()) : SqlConvert.ChangeTypeForXML(obj, type));
477 }
478 xmlReader.Read();
479 }
480 }
481 }
482 else
483 {
485 obj = xmlSerializer.Deserialize(xmlReader);
486 }
487 return obj;
488 }
static Type GetType(string value)
DataStorage(DataColumn column, Type type, object defaultValue, StorageType storageType)
static XmlSerializer GetXmlSerializer(Type type)

References System.Data.Common.DataStorage._dataType, System.array, System.Data.ExceptionBuilder.CanNotDeserializeObjectType(), System.Data.Common.SqlConvert.ChangeTypeForXML(), System.Activator.CreateInstance(), System.Xml.Dictionary, System.Data.TypeLimiter.EnsureTypeIsAllowed(), System.Convert.FromBase64String(), System.Type.GetType(), System.Data.Common.DataStorage.GetType(), System.Data.Common.ObjectStorage.GetXmlSerializer(), System.obj, System.text, System.type, and System.Data.XSDSchema.XsdtoClr().