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

◆ InferElement()

void System.Xml.Schema.XmlSchemaInference.InferElement ( XmlSchemaElement xse,
bool bCreatingNewType,
XmlSchema parentSchema )
inlinepackage

Definition at line 495 of file XmlSchemaInference.cs.

496 {
498 int lastUsedSeqItem = -1;
499 Hashtable hashtable = new Hashtable();
501 XmlSchemaComplexType xmlSchemaComplexType = effectiveSchemaType as XmlSchemaComplexType;
503 {
505 }
506 else if (!bCreatingNewType && xmlSchemaComplexType != null)
507 {
509 }
510 if (xmlSchemaComplexType == null || xmlSchemaComplexType == XmlSchemaComplexType.AnyType)
511 {
512 xmlSchemaComplexType = xse.SchemaType as XmlSchemaComplexType;
513 }
514 if (isEmptyElement)
515 {
516 if (!bCreatingNewType)
517 {
518 if (xmlSchemaComplexType != null)
519 {
520 if (xmlSchemaComplexType.Particle != null)
521 {
523 }
524 else if (xmlSchemaComplexType.ContentModel != null)
525 {
529 }
530 }
531 else if (!xse.SchemaTypeName.IsEmpty)
532 {
533 xse.LineNumber = 262144;
535 }
536 }
537 else
538 {
539 xse.LineNumber = 262144;
540 }
541 return;
542 }
543 bool flag = false;
544 do
545 {
546 _xtr.Read();
547 if (_xtr.NodeType == XmlNodeType.Whitespace)
548 {
549 flag = true;
550 }
551 if (_xtr.NodeType == XmlNodeType.EntityReference)
552 {
553 throw new XmlSchemaInferenceException(System.SR.SchInf_entity, 0, 0);
554 }
555 }
556 while (!_xtr.EOF && _xtr.NodeType != XmlNodeType.EndElement && _xtr.NodeType != XmlNodeType.CDATA && _xtr.NodeType != XmlNodeType.Element && _xtr.NodeType != XmlNodeType.Text);
557 if (_xtr.NodeType == XmlNodeType.EndElement)
558 {
559 if (flag)
560 {
561 if (xmlSchemaComplexType != null)
562 {
563 if (xmlSchemaComplexType.ContentModel != null)
564 {
568 }
569 else if (bCreatingNewType)
570 {
571 XmlSchemaSimpleContent xmlSchemaSimpleContent = (XmlSchemaSimpleContent)(xmlSchemaComplexType.ContentModel = new XmlSchemaSimpleContent());
572 XmlSchemaSimpleContentExtension xmlSchemaSimpleContentExtension3 = (XmlSchemaSimpleContentExtension)(xmlSchemaSimpleContent.Content = new XmlSchemaSimpleContentExtension());
576 }
577 else
578 {
580 }
581 }
582 else
583 {
585 xse.LineNumber = 262144;
586 }
587 }
589 {
590 xse.LineNumber = 262144;
591 }
592 else if (xmlSchemaComplexType != null)
593 {
594 if (xmlSchemaComplexType.Particle != null)
595 {
597 }
598 else if (xmlSchemaComplexType.ContentModel != null)
599 {
603 }
604 }
605 else if (!xse.SchemaTypeName.IsEmpty)
606 {
607 xse.LineNumber = 262144;
609 }
610 return;
611 }
612 int num = 0;
613 bool flag2 = false;
614 while (!_xtr.EOF && _xtr.NodeType != XmlNodeType.EndElement)
615 {
616 bool flag3 = false;
617 num++;
618 if (_xtr.NodeType == XmlNodeType.Text || _xtr.NodeType == XmlNodeType.CDATA)
619 {
620 if (xmlSchemaComplexType != null)
621 {
622 if (xmlSchemaComplexType.Particle != null)
623 {
625 if (num == 1)
626 {
627 do
628 {
629 _xtr.Read();
630 }
631 while (!_xtr.EOF && (_xtr.NodeType == XmlNodeType.CDATA || _xtr.NodeType == XmlNodeType.Text || _xtr.NodeType == XmlNodeType.Comment || _xtr.NodeType == XmlNodeType.ProcessingInstruction || _xtr.NodeType == XmlNodeType.Whitespace || _xtr.NodeType == XmlNodeType.SignificantWhitespace || _xtr.NodeType == XmlNodeType.XmlDeclaration));
632 flag3 = true;
633 if (_xtr.NodeType == XmlNodeType.EndElement)
634 {
636 }
637 }
638 }
639 else if (xmlSchemaComplexType.ContentModel != null)
640 {
642 if (_xtr.NodeType == XmlNodeType.Text && num == 1)
643 {
644 int num2 = -1;
645 if (xse.Parent == null)
646 {
648 }
649 else
650 {
652 xse.Parent = null;
653 }
656 }
657 else
658 {
661 }
662 }
663 else
664 {
665 XmlSchemaSimpleContent xmlSchemaSimpleContent2 = (XmlSchemaSimpleContent)(xmlSchemaComplexType.ContentModel = new XmlSchemaSimpleContent());
666 XmlSchemaSimpleContentExtension xmlSchemaSimpleContentExtension6 = (XmlSchemaSimpleContentExtension)(xmlSchemaSimpleContent2.Content = new XmlSchemaSimpleContentExtension());
668 if (_xtr.NodeType == XmlNodeType.Text)
669 {
670 int iTypeFlags = (bCreatingNewType ? (-1) : 262144);
673 }
674 else
675 {
678 }
679 }
680 }
681 else if (num > 1)
682 {
684 xse.LineNumber = 262144;
685 }
686 else
687 {
688 int iTypeFlags2 = -1;
690 {
691 if (_xtr.NodeType == XmlNodeType.Text)
692 {
695 }
696 else
697 {
699 xse.LineNumber = 262144;
700 }
701 }
702 else if (_xtr.NodeType == XmlNodeType.Text)
703 {
704 if (xse.Parent == null)
705 {
706 iTypeFlags2 = xse.LineNumber;
707 }
708 else
709 {
710 iTypeFlags2 = GetSchemaType(xse.SchemaTypeName);
711 if (iTypeFlags2 == -1 && xse.LineNumber == 262144)
712 {
713 iTypeFlags2 = 262144;
714 }
715 xse.Parent = null;
716 }
719 }
720 else
721 {
723 xse.LineNumber = 262144;
724 }
725 }
726 }
727 else if (_xtr.NodeType == XmlNodeType.Element)
728 {
729 XmlQualifiedName key = new XmlQualifiedName(_xtr.LocalName, _xtr.NamespaceURI);
730 bool setMaxoccurs = false;
731 if (hashtable.Contains(key))
732 {
733 setMaxoccurs = true;
734 }
735 else
736 {
737 hashtable.Add(key, null);
738 }
739 if (xmlSchemaComplexType == null)
740 {
741 xmlSchemaComplexType = (XmlSchemaComplexType)(xse.SchemaType = new XmlSchemaComplexType());
742 if (!xse.SchemaTypeName.IsEmpty)
743 {
745 xse.SchemaTypeName = XmlQualifiedName.Empty;
746 }
747 }
748 if (xmlSchemaComplexType.ContentModel != null)
749 {
750 XmlSchemaSimpleContentExtension scExtension = CheckSimpleContentExtension(xmlSchemaComplexType);
754 if (xmlSchemaComplexType.Particle != null)
755 {
756 throw new XmlSchemaInferenceException(System.SR.SchInf_particle, 0, 0);
757 }
758 xmlSchemaComplexType.Particle = new XmlSchemaSequence();
759 flag2 = true;
760 AddElement(_xtr.LocalName, _xtr.Prefix, _xtr.NamespaceURI, parentSchema, ((XmlSchemaSequence)xmlSchemaComplexType.Particle).Items, -1);
761 lastUsedSeqItem = 0;
762 if (!bCreatingNewType)
763 {
765 }
766 }
767 else if (xmlSchemaComplexType.Particle == null)
768 {
769 xmlSchemaComplexType.Particle = new XmlSchemaSequence();
770 flag2 = true;
771 AddElement(_xtr.LocalName, _xtr.Prefix, _xtr.NamespaceURI, parentSchema, ((XmlSchemaSequence)xmlSchemaComplexType.Particle).Items, -1);
772 if (!bCreatingNewType)
773 {
774 ((XmlSchemaSequence)xmlSchemaComplexType.Particle).MinOccurs = 0m;
775 }
776 lastUsedSeqItem = 0;
777 }
778 else
779 {
780 bool bParticleChanged = false;
782 }
783 }
784 else if (_xtr.NodeType == XmlNodeType.Text)
785 {
786 if (xmlSchemaComplexType == null)
787 {
788 throw new XmlSchemaInferenceException(System.SR.SchInf_ct, 0, 0);
789 }
791 }
792 do
793 {
794 if (_xtr.NodeType == XmlNodeType.EntityReference)
795 {
796 throw new XmlSchemaInferenceException(System.SR.SchInf_entity, 0, 0);
797 }
798 if (!flag3)
799 {
800 _xtr.Read();
801 }
802 else
803 {
804 flag3 = false;
805 }
806 }
807 while (!_xtr.EOF && _xtr.NodeType != XmlNodeType.EndElement && _xtr.NodeType != XmlNodeType.CDATA && _xtr.NodeType != XmlNodeType.Element && _xtr.NodeType != XmlNodeType.Text);
808 }
809 if (lastUsedSeqItem == -1)
810 {
811 return;
812 }
813 while (++lastUsedSeqItem < ((XmlSchemaSequence)xmlSchemaComplexType.Particle).Items.Count)
814 {
815 if (((XmlSchemaSequence)xmlSchemaComplexType.Particle).Items[lastUsedSeqItem].GetType() != typeof(XmlSchemaElement))
816 {
817 throw new XmlSchemaInferenceException(System.SR.SchInf_seq, 0, 0);
818 }
819 XmlSchemaElement xmlSchemaElement = (XmlSchemaElement)((XmlSchemaSequence)xmlSchemaComplexType.Particle).Items[lastUsedSeqItem];
821 }
822 }
virtual bool Contains(object key)
Definition Hashtable.cs:719
virtual void Add(object key, object? value)
Definition Hashtable.cs:676
static string SchInf_seq
Definition SR.cs:1220
static string SchInf_particle
Definition SR.cs:1216
static string SchInf_entity
Definition SR.cs:1210
static string SchInf_ct
Definition SR.cs:1218
Definition SR.cs:7
XmlSchemaElement FindMatchingElement(bool bCreatingNewType, XmlReader xtr, XmlSchemaComplexType ct, ref int lastUsedSeqItem, ref bool bParticleChanged, XmlSchema parentSchema, bool setMaxoccurs)
void ProcessAttributes(ref XmlSchemaElement xse, XmlSchemaType effectiveSchemaType, bool bCreatingNewType, XmlSchema parentSchema)
XmlQualifiedName RefineSimpleType(string s, ref int iTypeFlags)
XmlSchemaType GetEffectiveSchemaType(XmlSchemaElement elem, bool bCreatingNewType)
void MakeExistingAttributesOptional(XmlSchemaComplexType ct, XmlSchemaObjectCollection attributesInInstance)
XmlSchemaElement AddElement(string localName, string prefix, string childURI, XmlSchema parentSchema, XmlSchemaObjectCollection addLocation, int positionWithinCollection)
static int GetSchemaType(XmlQualifiedName qname)
void MoveAttributes(XmlSchemaSimpleContentExtension scExtension, XmlSchemaComplexType ct)
XmlSchemaSimpleContentExtension CheckSimpleContentExtension(XmlSchemaComplexType ct)
XmlNodeType NodeType
Definition XmlReader.cs:62

References System.Collections.Hashtable.Add(), System.Xml.Schema.XmlSchemaComplexType.AnyType, System.Xml.Schema.XmlSchemaSimpleContentExtension.BaseTypeName, System.Collections.Hashtable.Contains(), System.Xml.Schema.XmlSchemaSimpleContent.Content, System.Xml.Schema.XmlSchemaComplexType.ContentModel, System.Xml.XmlQualifiedName.Empty, System.Xml.XmlReader.EOF, System.Xml.XmlQualifiedName.IsEmpty, System.Xml.XmlReader.IsEmptyElement, System.Xml.Schema.XmlSchema.Items, System.key, System.Xml.Schema.XmlSchemaObject.LineNumber, System.Xml.XmlReader.LocalName, System.Xml.XmlReader.MoveToFirstAttribute(), System.Xml.XmlReader.NamespaceURI, System.Xml.XmlReader.NodeType, System.Xml.Schema.XmlSchemaObject.Parent, System.Xml.Schema.XmlSchemaComplexType.Particle, System.Xml.XmlReader.Prefix, System.Xml.XmlReader.Read(), System.Xml.Schema.XmlSchemaElement.SchemaType, System.Xml.Schema.XmlSchemaElement.SchemaTypeName, System.SR.SchInf_ct, System.SR.SchInf_entity, System.SR.SchInf_particle, System.SR.SchInf_seq, and System.Xml.XmlReader.Value.

Referenced by System.Xml.Schema.XmlSchemaInference.InferSchema1().