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

◆ FindMatchingElement()

XmlSchemaElement System.Xml.Schema.XmlSchemaInference.FindMatchingElement ( bool bCreatingNewType,
XmlReader xtr,
XmlSchemaComplexType ct,
ref int lastUsedSeqItem,
ref bool bParticleChanged,
XmlSchema parentSchema,
bool setMaxoccurs )
inlinepackage

Definition at line 863 of file XmlSchemaInference.cs.

864 {
865 if (xtr.NamespaceURI == "http://www.w3.org/2001/XMLSchema")
866 {
867 throw new XmlSchemaInferenceException(System.SR.SchInf_schema, 0, 0);
868 }
869 bool flag = lastUsedSeqItem == -1;
870 XmlSchemaObjectCollection xmlSchemaObjectCollection = new XmlSchemaObjectCollection();
871 if (ct.Particle.GetType() == typeof(XmlSchemaSequence))
872 {
873 string text = xtr.NamespaceURI;
874 if (text.Length == 0)
875 {
876 text = null;
877 }
878 XmlSchemaSequence xmlSchemaSequence = (XmlSchemaSequence)ct.Particle;
879 if (xmlSchemaSequence.Items.Count < 1 && !bCreatingNewType)
880 {
881 lastUsedSeqItem = 0;
882 XmlSchemaElement xmlSchemaElement = AddElement(xtr.LocalName, xtr.Prefix, xtr.NamespaceURI, parentSchema, xmlSchemaSequence.Items, -1);
884 return xmlSchemaElement;
885 }
886 if (xmlSchemaSequence.Items[0].GetType() == typeof(XmlSchemaChoice))
887 {
888 XmlSchemaChoice xmlSchemaChoice = (XmlSchemaChoice)xmlSchemaSequence.Items[0];
889 for (int i = 0; i < xmlSchemaChoice.Items.Count; i++)
890 {
891 if (!(xmlSchemaChoice.Items[i] is XmlSchemaElement xmlSchemaElement2))
892 {
893 throw new XmlSchemaInferenceException(System.SR.SchInf_UnknownParticle, 0, 0);
894 }
895 if (xmlSchemaElement2.Name == xtr.LocalName && parentSchema.TargetNamespace == text)
896 {
899 return xmlSchemaElement2;
900 }
901 if (xmlSchemaElement2.RefName.Name == xtr.LocalName && xmlSchemaElement2.RefName.Namespace == xtr.NamespaceURI)
902 {
903 XmlSchemaElement xmlSchemaElement3 = FindGlobalElement(text, xtr.LocalName, out parentSchema);
906 return xmlSchemaElement3;
907 }
908 }
909 return AddElement(xtr.LocalName, xtr.Prefix, xtr.NamespaceURI, parentSchema, xmlSchemaChoice.Items, -1);
910 }
911 int num = 0;
912 if (lastUsedSeqItem >= 0)
913 {
914 num = lastUsedSeqItem;
915 }
916 XmlSchemaParticle xmlSchemaParticle = xmlSchemaSequence.Items[num] as XmlSchemaParticle;
917 if (!(xmlSchemaParticle is XmlSchemaElement xmlSchemaElement4))
918 {
919 throw new XmlSchemaInferenceException(System.SR.SchInf_UnknownParticle, 0, 0);
920 }
921 if (xmlSchemaElement4.Name == xtr.LocalName && parentSchema.TargetNamespace == text)
922 {
923 if (!flag)
924 {
925 xmlSchemaElement4.MaxOccurs = decimal.MaxValue;
926 }
927 lastUsedSeqItem = num;
930 return xmlSchemaElement4;
931 }
932 if (xmlSchemaElement4.RefName.Name == xtr.LocalName && xmlSchemaElement4.RefName.Namespace == xtr.NamespaceURI)
933 {
934 if (!flag)
935 {
936 xmlSchemaElement4.MaxOccurs = decimal.MaxValue;
937 }
938 lastUsedSeqItem = num;
939 XmlSchemaElement xse = FindGlobalElement(text, xtr.LocalName, out parentSchema);
942 return xmlSchemaElement4;
943 }
944 if (flag && xmlSchemaElement4.MinOccurs != 0m)
945 {
947 }
948 for (num++; num < xmlSchemaSequence.Items.Count; num++)
949 {
950 xmlSchemaParticle = xmlSchemaSequence.Items[num] as XmlSchemaParticle;
951 if (!(xmlSchemaParticle is XmlSchemaElement xmlSchemaElement5))
952 {
953 throw new XmlSchemaInferenceException(System.SR.SchInf_UnknownParticle, 0, 0);
954 }
955 if (xmlSchemaElement5.Name == xtr.LocalName && parentSchema.TargetNamespace == text)
956 {
957 lastUsedSeqItem = num;
958 for (int j = 0; j < xmlSchemaObjectCollection.Count; j++)
959 {
960 ((XmlSchemaElement)xmlSchemaObjectCollection[j]).MinOccurs = 0m;
961 }
964 return xmlSchemaElement5;
965 }
966 if (xmlSchemaElement5.RefName.Name == xtr.LocalName && xmlSchemaElement5.RefName.Namespace == xtr.NamespaceURI)
967 {
968 lastUsedSeqItem = num;
969 for (int k = 0; k < xmlSchemaObjectCollection.Count; k++)
970 {
971 ((XmlSchemaElement)xmlSchemaObjectCollection[k]).MinOccurs = 0m;
972 }
973 XmlSchemaElement xmlSchemaElement6 = FindGlobalElement(text, xtr.LocalName, out parentSchema);
976 return xmlSchemaElement6;
977 }
979 }
980 XmlSchemaElement xmlSchemaElement7 = null;
981 XmlSchemaElement xse2 = null;
982 if (parentSchema.TargetNamespace == text)
983 {
986 }
987 else
988 {
989 xmlSchemaElement7 = FindElementRef(xmlSchemaSequence.Items, xtr.LocalName, xtr.NamespaceURI);
990 if (xmlSchemaElement7 != null)
991 {
993 }
994 }
995 if (xmlSchemaElement7 != null)
996 {
997 XmlSchemaChoice xmlSchemaChoice2 = new XmlSchemaChoice();
998 xmlSchemaChoice2.MaxOccurs = decimal.MaxValue;
1001 for (int l = 0; l < xmlSchemaSequence.Items.Count; l++)
1002 {
1003 xmlSchemaChoice2.Items.Add(CreateNewElementforChoice((XmlSchemaElement)xmlSchemaSequence.Items[l]));
1004 }
1005 xmlSchemaSequence.Items.Clear();
1007 return xmlSchemaElement7;
1008 }
1009 xmlSchemaElement7 = AddElement(xtr.LocalName, xtr.Prefix, xtr.NamespaceURI, parentSchema, xmlSchemaSequence.Items, ++lastUsedSeqItem);
1010 if (!bCreatingNewType)
1011 {
1013 }
1014 return xmlSchemaElement7;
1015 }
1016 throw new XmlSchemaInferenceException(System.SR.SchInf_noseq, 0, 0);
1017 }
static string SchInf_noseq
Definition SR.cs:1222
static string SchInf_UnknownParticle
Definition SR.cs:1226
static string SchInf_schema
Definition SR.cs:1208
Definition SR.cs:7
XmlSchemaElement FindElement(XmlSchemaObjectCollection elements, string elementName)
XmlSchemaElement FindGlobalElement(string namespaceURI, string localName, out XmlSchema parentSchema)
void SetMinMaxOccurs(XmlSchemaElement el, bool setMaxOccurs)
XmlSchemaElement FindElementRef(XmlSchemaObjectCollection elements, string elementName, string nsURI)
XmlSchemaElement CreateNewElementforChoice(XmlSchemaElement copyElement)
void InferElement(XmlSchemaElement xse, bool bCreatingNewType, XmlSchema parentSchema)
XmlSchemaElement AddElement(string localName, string prefix, string childURI, XmlSchema parentSchema, XmlSchemaObjectCollection addLocation, int positionWithinCollection)

References System.Xml.Schema.XmlSchemaObjectCollection.Add(), System.Collections.CollectionBase.Clear(), System.Collections.CollectionBase.Count, System.Xml.Schema.XmlSchemaChoice.Items, System.Xml.Schema.XmlSchemaSequence.Items, System.Xml.XmlReader.LocalName, System.Xml.XmlReader.NamespaceURI, System.Xml.Schema.XmlSchemaComplexType.Particle, System.Xml.XmlReader.Prefix, System.SR.SchInf_noseq, System.SR.SchInf_schema, System.SR.SchInf_UnknownParticle, System.Xml.Schema.XmlSchema.TargetNamespace, and System.text.