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

◆ InitializeStructMembers()

bool System.Xml.Serialization.XmlReflectionImporter.InitializeStructMembers ( StructMapping mapping,
StructModel model,
bool openModel,
string typeName,
RecursionLimiter limiter )
inlineprivate

Definition at line 771 of file XmlReflectionImporter.cs.

772 {
773 if (mapping.IsFullyInitialized)
774 {
775 return true;
776 }
777 if (model.TypeDesc.BaseTypeDesc != null)
778 {
779 TypeModel typeModel = _modelScope.GetTypeModel(model.Type.BaseType, directReference: false);
780 if (!(typeModel is StructModel))
781 {
782 throw new NotSupportedException(System.SR.Format(System.SR.XmlUnsupportedInheritance, model.Type.BaseType.FullName));
783 }
784 StructMapping structMapping = ImportStructLikeMapping((StructModel)typeModel, mapping.Namespace, openModel, null, limiter);
785 int num = limiter.DeferredWorkItems.IndexOf(structMapping);
786 if (num >= 0)
787 {
788 if (!limiter.DeferredWorkItems.Contains(mapping))
789 {
790 limiter.DeferredWorkItems.Add(new ImportStructWorkItem(model, mapping));
791 }
793 if (num < num2)
794 {
795 ImportStructWorkItem value = limiter.DeferredWorkItems[num];
796 limiter.DeferredWorkItems[num] = limiter.DeferredWorkItems[num2];
797 limiter.DeferredWorkItems[num2] = value;
798 }
799 return false;
800 }
802 ICollection values = mapping.BaseMapping.LocalAttributes.Values;
803 foreach (AttributeAccessor item in values)
804 {
805 AddUniqueAccessor(mapping.LocalAttributes, item);
806 }
807 if (!mapping.BaseMapping.HasExplicitSequence())
808 {
809 values = mapping.BaseMapping.LocalElements.Values;
810 foreach (ElementAccessor item2 in values)
811 {
812 AddUniqueAccessor(mapping.LocalElements, item2);
813 }
814 }
815 }
817 TextAccessor textAccessor = null;
818 bool hasElements = false;
819 bool flag = false;
820 MemberInfo[] memberInfos = model.GetMemberInfos();
821 foreach (MemberInfo memberInfo in memberInfos)
822 {
824 {
825 continue;
826 }
827 XmlAttributes attributes = GetAttributes(memberInfo);
828 if (attributes.XmlIgnore)
829 {
830 continue;
831 }
832 FieldModel fieldModel = model.GetFieldModel(memberInfo);
833 if (fieldModel == null)
834 {
835 continue;
836 }
837 try
838 {
839 MemberMapping memberMapping = ImportFieldMapping(model, fieldModel, attributes, mapping.Namespace, limiter);
840 if (memberMapping == null || (mapping.BaseMapping != null && mapping.BaseMapping.Declares(memberMapping, mapping.TypeName)))
841 {
842 continue;
843 }
844 flag |= memberMapping.IsSequence;
845 AddUniqueAccessor(memberMapping, mapping.LocalElements, mapping.LocalAttributes, flag);
846 if (memberMapping.Text != null)
847 {
848 if (!memberMapping.Text.Mapping.TypeDesc.CanBeTextValue && memberMapping.Text.Mapping.IsList)
849 {
850 throw new InvalidOperationException(System.SR.Format(System.SR.XmlIllegalTypedTextAttribute, typeName, memberMapping.Text.Name, memberMapping.Text.Mapping.TypeDesc.FullName));
851 }
852 if (textAccessor != null)
853 {
855 }
857 }
858 if (memberMapping.Xmlns != null)
859 {
860 if (mapping.XmlnsMember != null)
861 {
863 }
865 }
866 if (memberMapping.Elements != null && memberMapping.Elements.Length != 0)
867 {
868 hasElements = true;
869 }
871 }
872 catch (Exception ex)
873 {
874 if (ex is OutOfMemoryException)
875 {
876 throw;
877 }
879 }
880 }
881 mapping.SetContentModel(textAccessor, hasElements);
882 if (flag)
883 {
884 Hashtable hashtable = new Hashtable();
885 for (int j = 0; j < list.Count; j++)
886 {
887 MemberMapping memberMapping2 = list[j];
888 if (memberMapping2.IsParticle)
889 {
890 if (!memberMapping2.IsSequence)
891 {
893 }
894 if (hashtable[memberMapping2.SequenceId] != null)
895 {
897 }
898 hashtable[memberMapping2.SequenceId] = memberMapping2;
899 }
900 }
901 list.Sort(new MemberMappingComparer());
902 }
903 mapping.Members = list.ToArray();
904 if (mapping.BaseMapping == null)
905 {
907 }
908 if (mapping.XmlnsMember != null && mapping.BaseMapping.HasXmlnsMember)
909 {
911 }
914 if (openModel)
915 {
916 mapping.IsOpenModel = true;
917 }
918 return true;
919 }
bool ICollection< KeyValuePair< TKey, TValue > >. Contains(KeyValuePair< TKey, TValue > keyValuePair)
void Add(TKey key, TValue value)
static CultureInfo InvariantCulture
static string XmlSequenceUnique
Definition SR.cs:1798
static string XmlMultipleXmlns
Definition SR.cs:1688
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string XmlIllegalTypedTextAttribute
Definition SR.cs:1676
static string XmlSequenceInconsistent
Definition SR.cs:1796
static string XmlIllegalMultipleText
Definition SR.cs:1670
static string XmlUnsupportedInheritance
Definition SR.cs:1668
Definition SR.cs:7
TypeModel GetTypeModel(Type type)
Definition ModelScope.cs:22
void AddTypeMapping(TypeMapping typeMapping)
Definition TypeScope.cs:930
MemberMapping ImportFieldMapping(StructModel parent, FieldModel model, XmlAttributes a, string ns, RecursionLimiter limiter)
static void AddUniqueAccessor(INameScope scope, Accessor accessor)
void IncludeTypes(ICustomAttributeProvider provider)
StructMapping ImportStructLikeMapping(StructModel model, string ns, bool openModel, XmlAttributes a, RecursionLimiter limiter)
Exception CreateMemberReflectionException(FieldModel model, Exception e)
XmlAttributes GetAttributes(Type type, bool canBeSimpleType)

References System.Xml.Serialization.XmlReflectionImporter._modelScope, System.Xml.Serialization.XmlReflectionImporter._typeScope, System.Collections.Generic.Dictionary< TKey, TValue >.Add(), System.Xml.Serialization.TypeScope.AddTypeMapping(), System.Xml.Serialization.XmlReflectionImporter.AddUniqueAccessor(), System.Collections.Generic.Dictionary< TKey, TValue >.Contains(), System.Collections.Generic.Dictionary< TKey, TValue >.Count, System.Xml.Serialization.XmlReflectionImporter.CreateMemberReflectionException(), System.Xml.Dictionary, System.SR.Format(), System.Xml.Serialization.XmlReflectionImporter.GetAttributes(), System.Xml.Serialization.XmlReflectionImporter.GetRootMapping(), System.Xml.Serialization.ModelScope.GetTypeModel(), System.Xml.Serialization.XmlReflectionImporter.ImportFieldMapping(), System.Xml.Serialization.XmlReflectionImporter.ImportStructLikeMapping(), System.Xml.Serialization.XmlReflectionImporter.IncludeTypes(), System.Globalization.CultureInfo.InvariantCulture, System.item, System.list, System.value, System.Collections.Generic.Dictionary< TKey, TValue >.Values, System.values, System.Xml.Serialization.XmlAttributes.XmlIgnore, System.SR.XmlIllegalMultipleText, System.SR.XmlIllegalTypedTextAttribute, System.SR.XmlMultipleXmlns, System.SR.XmlSequenceInconsistent, System.SR.XmlSequenceUnique, and System.SR.XmlUnsupportedInheritance.

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