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

◆ LoadSchema() [1/2]

void System.Data.XSDSchema.LoadSchema ( XmlSchemaSet schemaSet,
DataSet ds )
inline

Definition at line 600 of file XSDSchema.cs.

601 {
603 _refTables = new ArrayList();
605 _complexTypes = new ArrayList();
606 bool flag = false;
607 bool isNewDataSet = ds.Tables.Count == 0;
608 if (schemaSet == null)
609 {
610 return;
611 }
613 _ds = ds;
616 try
617 {
618 if (enumerator.MoveNext())
619 {
622 if (_schemaName == null || _schemaName.Length == 0)
623 {
624 _schemaName = "NewDataSet";
625 }
627 string targetNamespace = xmlSchema.TargetNamespace;
628 if (ds._namespaceURI == null || ds._namespaceURI.Length == 0)
629 {
630 ds._namespaceURI = ((targetNamespace == null) ? string.Empty : targetNamespace);
631 }
632 }
633 }
634 finally
635 {
636 IDisposable disposable = enumerator as IDisposable;
637 if (disposable != null)
638 {
639 disposable.Dispose();
640 }
641 }
645 _attributes = new Hashtable();
647 _schemaTypes = new Hashtable();
650 foreach (DataTable table in ds.Tables)
651 {
652 foreach (DataColumn column in table.Columns)
653 {
654 if (column.SimpleType != null && column.SimpleType.Name != null && column.SimpleType.Name.Length != 0)
655 {
656 _existingSimpleTypeMap[column.SimpleType.SimpleTypeQualifiedName] = column;
657 }
658 }
659 }
660 foreach (XmlSchema item in schemaSet.Schemas())
661 {
663 }
665 if (_dsElement != null)
666 {
667 string stringAttribute = GetStringAttribute(_dsElement, "MainDataTable", "");
668 if (stringAttribute != null)
669 {
671 }
672 }
673 else
674 {
675 if (FromInference)
676 {
677 ds._fTopLevelTable = true;
678 }
679 flag = true;
680 }
682 if (ds != null && ds._useDataSetSchemaOnly)
683 {
685 if (num == 0)
686 {
687 throw ExceptionBuilder.IsDataSetAttributeMissingInSchema();
688 }
689 if (num > 1)
690 {
691 throw ExceptionBuilder.TooManyIsDataSetAttributesInSchema();
692 }
694 if (xmlSchemaComplexType.Particle != null)
695 {
697 if (particleItems != null)
698 {
700 {
701 if (item2 is XmlSchemaElement xmlSchemaElement && xmlSchemaElement.RefName.Name.Length != 0)
702 {
703 list.Add(xmlSchemaElement.QualifiedName);
704 }
705 }
706 }
707 }
708 }
709 foreach (XmlSchemaElement element in _elements)
710 {
711 if (element != _dsElement && (ds == null || !ds._useDataSetSchemaOnly || _dsElement == null || _dsElement.Parent == element.Parent || list.Contains(element.QualifiedName)))
712 {
713 string instanceName = GetInstanceName(element);
715 {
717 }
718 else
719 {
720 HandleTable(element);
721 }
722 }
723 }
724 if (_dsElement != null)
725 {
727 }
728 foreach (XmlSchemaAnnotation annotation in _annotations)
729 {
730 HandleRelations(annotation, fNested: false);
731 }
732 for (int i = 0; i < _columnExpressions.Count; i++)
733 {
734 DataColumn dataColumn2 = (DataColumn)_columnExpressions[i];
736 }
737 foreach (DataTable table2 in ds.Tables)
738 {
739 if (table2.NestedParentRelations.Length != 0 || !(table2.Namespace == ds.Namespace))
740 {
741 continue;
742 }
743 DataRelationCollection childRelations = table2.ChildRelations;
744 for (int j = 0; j < childRelations.Count; j++)
745 {
746 if (childRelations[j].Nested && table2.Namespace == childRelations[j].ChildTable.Namespace)
747 {
748 childRelations[j].ChildTable._tableNamespace = null;
749 }
750 }
752 }
753 DataTable dataTable3 = ds.Tables[ds.DataSetName, ds.Namespace];
754 if (dataTable3 != null)
755 {
757 }
758 if (FromInference && ds.Tables.Count == 0 && string.Equals(ds.DataSetName, "NewDataSet", StringComparison.Ordinal))
759 {
761 }
762 ds._fIsSchemaLoading = false;
763 if (!flag)
764 {
765 return;
766 }
767 if (ds.Tables.Count > 0)
768 {
769 ds.Namespace = ds.Tables[0].Namespace;
770 ds.Prefix = ds.Tables[0].Prefix;
771 return;
772 }
773 foreach (XmlSchema item3 in schemaSet.Schemas())
774 {
775 ds.Namespace = item3.TargetNamespace;
776 }
777 }
virtual bool Contains(object? item)
string GetInstanceName(XmlSchemaAnnotated node)
Hashtable _constraintNodes
Definition XSDSchema.cs:43
int DatasetElementCount(XmlSchemaObjectCollection elements)
Definition XSDSchema.cs:514
ArrayList _complexTypes
Definition XSDSchema.cs:47
void CollectElementsAnnotations(XmlSchema schema)
Definition XSDSchema.cs:131
string GetStringAttribute(XmlSchemaAnnotated element, string attrName, string defVal)
XmlSchemaSet _schemaSet
Definition XSDSchema.cs:33
Dictionary< DataTable, List< DataTable > > _tableDictionary
Definition XSDSchema.cs:63
XmlSchemaObjectCollection _elements
Definition XSDSchema.cs:51
Hashtable _expressions
Definition XSDSchema.cs:61
XmlSchemaElement _dsElement
Definition XSDSchema.cs:35
ArrayList _columnExpressions
Definition XSDSchema.cs:41
Hashtable _schemaTypes
Definition XSDSchema.cs:59
XmlSchemaObjectCollection _annotations
Definition XSDSchema.cs:49
XmlSchemaElement FindDatasetElement(XmlSchemaObjectCollection elements)
Definition XSDSchema.cs:527
void HandleRefTableProperties(ArrayList RefTables, XmlSchemaElement element)
Definition XSDSchema.cs:378
DataTable HandleTable(XmlSchemaElement node)
Hashtable _elementsTable
Definition XSDSchema.cs:55
Hashtable _attributeGroups
Definition XSDSchema.cs:57
void HandleDataSet(XmlSchemaElement node, bool isNewDataSet)
XmlSchemaObjectCollection GetParticleItems(XmlSchemaParticle pt)
Definition XSDSchema.cs:799
XmlSchemaAnnotated FindTypeNode(XmlSchemaAnnotated node)
Hashtable _attributes
Definition XSDSchema.cs:53
Hashtable _existingSimpleTypeMap
Definition XSDSchema.cs:67
void HandleRelations(XmlSchemaAnnotation ann, bool fNested)
Definition XSDSchema.cs:780
static ? string DecodeName(string? name)
Definition XmlConvert.cs:55

References System.Data.XSDSchema._annotations, System.Data.XSDSchema._attributeGroups, System.Data.XSDSchema._attributes, System.Data.XSDSchema._columnExpressions, System.Data.XSDSchema._complexTypes, System.Data.XSDSchema._constraintNodes, System.Data.XSDSchema._ds, System.Data.XSDSchema._dsElement, System.Data.XSDSchema._elements, System.Data.XSDSchema._elementsTable, System.Data.XSDSchema._existingSimpleTypeMap, System.Data.XSDSchema._expressions, System.Data.XSDSchema._refTables, System.Data.XSDSchema._schemaName, System.Data.XSDSchema._schemaSet, System.Data.XSDSchema._schemaTypes, System.Data.XSDSchema._tableDictionary, System.Data.XSDSchema.CollectElementsAnnotations(), System.Data.DataTable.Columns, System.Collections.ArrayList.Contains(), System.Collections.Generic.Dictionary< TKey, TValue >.Count, System.Collections.ArrayList.Count, System.Data.XSDSchema.DatasetElementCount(), System.Xml.XmlConvert.DecodeName(), System.Xml.Dictionary, System.Data.XSDSchema.FindDatasetElement(), System.Data.XSDSchema.FindTypeNode(), System.Data.XSDSchema.FromInference, System.Collections.Generic.Dictionary< TKey, TValue >.GetEnumerator(), System.Data.XSDSchema.GetInstanceName(), System.Data.XSDSchema.GetParticleItems(), System.Data.XSDSchema.GetStringAttribute(), System.Data.XSDSchema.HandleDataSet(), System.Data.XSDSchema.HandleRefTableProperties(), System.Data.XSDSchema.HandleRelations(), System.Data.XSDSchema.HandleTable(), System.Data.ExceptionBuilder.IsDataSetAttributeMissingInSchema(), System.item, System.list, System.Data.Name, System.Xml.XmlQualifiedName.Namespace, System.Xml.Schema.XmlSchemaObject.Parent, System.Xml.Schema.XmlSchemaElement.QualifiedName, and System.Data.ExceptionBuilder.TooManyIsDataSetAttributesInSchema().