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

◆ ImportStructType()

StructMapping System.Xml.Serialization.XmlSchemaImporter.ImportStructType ( XmlSchemaType type,
string typeNs,
string identifier,
Type baseType,
bool arrayLike )
inlineprivate

Definition at line 474 of file XmlSchemaImporter.cs.

475 {
476 TypeDesc typeDesc = null;
477 TypeMapping typeMapping = null;
478 bool flag = false;
479 if (!type.DerivedFrom.IsEmpty)
480 {
481 typeMapping = ImportType(type.DerivedFrom, typeof(TypeMapping), null, (TypeFlags)48, addref: false);
482 if (typeMapping is StructMapping)
483 {
484 typeDesc = ((StructMapping)typeMapping).TypeDesc;
485 }
486 else if (typeMapping is ArrayMapping)
487 {
488 typeMapping = ((ArrayMapping)typeMapping).TopLevelMapping;
489 if (typeMapping != null)
490 {
493 typeDesc = typeMapping.TypeDesc;
494 }
495 }
496 else
497 {
498 typeMapping = null;
499 }
500 }
501 if (typeDesc == null && baseType != null)
502 {
503 typeDesc = base.Scope.GetTypeDesc(baseType);
504 }
505 if (typeMapping == null)
506 {
508 flag = true;
509 }
510 Mapping mapping = (Mapping)base.ImportedMappings[type];
511 if (mapping != null)
512 {
513 if (mapping is StructMapping)
514 {
515 return (StructMapping)mapping;
516 }
517 if (!arrayLike || !(mapping is ArrayMapping))
518 {
519 throw new InvalidOperationException(System.SR.Format(System.SR.XmlTypeUsedTwice, type.QualifiedName.Name, type.QualifiedName.Namespace));
520 }
521 ArrayMapping arrayMapping = (ArrayMapping)mapping;
522 if (arrayMapping.TopLevelMapping != null)
523 {
524 return arrayMapping.TopLevelMapping;
525 }
526 }
527 StructMapping structMapping = new StructMapping();
528 structMapping.IsReference = base.Schemas.IsReference(type);
529 TypeFlags typeFlags = TypeFlags.Reference;
531 {
532 typeFlags |= TypeFlags.Abstract;
533 }
534 identifier = Accessor.UnescapeName(identifier);
536 structMapping.TypeDesc = new TypeDesc(text, text, TypeKind.Struct, typeDesc, typeFlags);
538 structMapping.TypeName = ((type.Name == null || type.Name.Length == 0) ? null : identifier);
539 structMapping.BaseMapping = (StructMapping)typeMapping;
540 if (!arrayLike)
541 {
542 base.ImportedMappings.Add(type, structMapping);
543 }
544 CodeIdentifiers codeIdentifiers = new CodeIdentifiers();
545 CodeIdentifiers codeIdentifiers2 = structMapping.BaseMapping.Scope.Clone();
546 codeIdentifiers.AddReserved(text);
547 codeIdentifiers2.AddReserved(text);
549 if (flag)
550 {
552 }
553 bool needExplicitOrder = false;
555 if (!IsAllGroup(type))
556 {
558 {
559 structMapping.SetSequence();
560 }
561 else if (GenerateOrder)
562 {
564 }
565 }
566 for (int i = 0; i < structMapping.Members.Length; i++)
567 {
568 StructMapping declaringMapping;
569 MemberMapping memberMapping = ((StructMapping)typeMapping).FindDeclaringMapping(structMapping.Members[i], out declaringMapping, structMapping.TypeName);
570 if (memberMapping != null && memberMapping.TypeDesc != structMapping.Members[i].TypeDesc)
571 {
572 throw new InvalidOperationException(System.SR.Format(System.SR.XmlIllegalOverride, type.Name, memberMapping.Name, memberMapping.TypeDesc.FullName, structMapping.Members[i].TypeDesc.FullName, declaringMapping.TypeDesc.FullName));
573 }
574 }
576 base.Scope.AddTypeMapping(structMapping);
577 return structMapping;
578 }
void Add(TKey key, TValue value)
static string XmlTypeUsedTwice
Definition SR.cs:1494
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string XmlIllegalOverride
Definition SR.cs:1622
Definition SR.cs:7
void AddReservedIdentifiersForDataBinding(CodeIdentifiers scope)
TypeMapping ImportType(XmlQualifiedName name, Type desiredMappingType, Type baseType, TypeFlags flags, bool addref)
MemberMapping[] ImportTypeMembers(XmlSchemaType type, string typeNs, string identifier, CodeIdentifiers members, CodeIdentifiers membersScope, INameScope elementsScope, ref bool needExplicitOrder, bool order, bool allowUnboundedElements)
string GenerateUniqueTypeName(string desiredName, string ns)

References System.Collections.Generic.Dictionary< TKey, TValue >.Add(), System.Xml.Serialization.SchemaImporter.AddReservedIdentifiersForDataBinding(), System.Xml.Dictionary, System.SR.Format(), System.Xml.Serialization.XmlSchemaImporter.GenerateOrder, System.Xml.Serialization.XmlSchemaImporter.GenerateUniqueTypeName(), System.Xml.Serialization.SchemaImporter.GetRootMapping(), System.Xml.Serialization.XmlSchemaImporter.ImportType(), System.Xml.Serialization.XmlSchemaImporter.ImportTypeMembers(), System.Xml.Serialization.XmlSchemaImporter.IsAllGroup(), System.text, System.type, System.Xml.Serialization.Accessor.UnescapeName(), System.SR.XmlIllegalOverride, and System.SR.XmlTypeUsedTwice.

Referenced by System.Xml.Serialization.XmlSchemaImporter.ImportArrayMapping(), and System.Xml.Serialization.XmlSchemaImporter.ImportType().