Terraria v1.4.4.9
Terraria source code documentation
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros

◆ SetArrayMappingType()

void System.Xml.Serialization.XmlReflectionImporter.SetArrayMappingType ( ArrayMapping mapping,
string defaultNs,
Type type )
inlineprivate

Definition at line 993 of file XmlReflectionImporter.cs.

994 {
995 XmlAttributes attributes = GetAttributes(type, canBeSimpleType: false);
996 if (IsAnonymousType(attributes, defaultNs))
997 {
998 mapping.TypeName = null;
999 mapping.Namespace = defaultNs;
1000 return;
1001 }
1002 ElementAccessor elementAccessor = null;
1003 TypeMapping typeMapping;
1004 if (mapping.Elements.Length == 1)
1005 {
1006 elementAccessor = mapping.Elements[0];
1007 typeMapping = elementAccessor.Mapping;
1008 }
1009 else
1010 {
1011 typeMapping = null;
1012 }
1013 bool flag = true;
1014 string text;
1015 string name;
1016 if (attributes.XmlType != null)
1017 {
1018 text = attributes.XmlType.Namespace;
1019 name = XsdTypeName(type, attributes, attributes.XmlType.TypeName);
1020 name = XmlConvert.EncodeLocalName(name);
1021 flag = name == null;
1022 }
1023 else if (typeMapping is EnumMapping)
1024 {
1025 text = typeMapping.Namespace;
1026 name = typeMapping.DefaultElementName;
1027 }
1028 else if (typeMapping is PrimitiveMapping)
1029 {
1030 text = defaultNs;
1031 name = typeMapping.TypeDesc.DataType.Name;
1032 }
1033 else if (typeMapping is StructMapping && typeMapping.TypeDesc.IsRoot)
1034 {
1035 text = defaultNs;
1036 name = "anyType";
1037 }
1038 else if (typeMapping != null)
1039 {
1040 text = ((typeMapping.Namespace == "http://www.w3.org/2001/XMLSchema") ? defaultNs : typeMapping.Namespace);
1041 name = typeMapping.DefaultElementName;
1042 }
1043 else
1044 {
1045 text = defaultNs;
1046 name = "Choice" + _choiceNum++;
1047 }
1048 if (name == null)
1049 {
1050 name = "Any";
1051 }
1052 if (elementAccessor != null)
1053 {
1054 text = elementAccessor.Namespace;
1055 }
1056 if (text == null)
1057 {
1058 text = defaultNs;
1059 }
1060 string text2 = (name = (flag ? ("ArrayOf" + CodeIdentifier.MakePascal(name)) : name));
1061 int num = 1;
1062 TypeMapping typeMapping2 = (TypeMapping)_types[text2, text];
1063 while (typeMapping2 != null)
1064 {
1065 if (typeMapping2 is ArrayMapping)
1066 {
1067 ArrayMapping arrayMapping = (ArrayMapping)typeMapping2;
1068 if (AccessorMapping.ElementsMatch(arrayMapping.Elements, mapping.Elements))
1069 {
1070 break;
1071 }
1072 }
1073 text2 = name + num.ToString(CultureInfo.InvariantCulture);
1074 typeMapping2 = (TypeMapping)_types[text2, text];
1075 num++;
1076 }
1079 }
static CultureInfo InvariantCulture
static bool IsAnonymousType(XmlAttributes a, string contextNs)
XmlAttributes GetAttributes(Type type, bool canBeSimpleType)

References System.Xml.Serialization.XmlReflectionImporter._choiceNum, System.Xml.Serialization.XmlReflectionImporter._types, System.Xml.Dictionary, System.Xml.Serialization.AccessorMapping.ElementsMatch(), System.Xml.XmlConvert.EncodeLocalName(), System.Xml.Serialization.XmlReflectionImporter.GetAttributes(), System.Globalization.CultureInfo.InvariantCulture, System.Xml.Serialization.XmlReflectionImporter.IsAnonymousType(), System.Xml.Serialization.CodeIdentifier.MakePascal(), System.Xml.Serialization.XmlTypeAttribute.Namespace, System.text, System.type, System.Xml.Serialization.XmlTypeAttribute.TypeName, System.Xml.Serialization.XmlAttributes.XmlType, and System.Xml.Serialization.XmlReflectionImporter.XsdTypeName().

Referenced by System.Xml.Serialization.XmlReflectionImporter.ImportArrayLikeMapping().