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

◆ ReadXml() [8/11]

XmlReadMode System.Data.DataSet.ReadXml ( XmlReader reader,
bool denyResolving )
inlinepackage

Definition at line 1691 of file DataSet.cs.

1692 {
1693 IDisposable disposable = null;
1694 long scopeId = DataCommonEventSource.Log.EnterScope("<ds.DataSet.ReadXml|INFO> {0}, denyResolving={1}", ObjectID, denyResolving);
1695 try
1696 {
1697 disposable = TypeLimiter.EnterRestrictedScope(this);
1698 DataTable.DSRowDiffIdUsageSection dSRowDiffIdUsageSection = default(DataTable.DSRowDiffIdUsageSection);
1699 try
1700 {
1701 bool flag = false;
1702 bool flag2 = false;
1703 bool flag3 = false;
1704 bool isXdr = false;
1705 int depth = -1;
1706 XmlReadMode result = XmlReadMode.Auto;
1707 bool flag4 = false;
1708 bool flag5 = false;
1709 dSRowDiffIdUsageSection.Prepare(this);
1710 if (reader == null)
1711 {
1712 return result;
1713 }
1714 if (Tables.Count == 0)
1715 {
1716 flag4 = true;
1717 }
1718 if (reader is XmlTextReader)
1719 {
1720 ((XmlTextReader)reader).WhitespaceHandling = WhitespaceHandling.Significant;
1721 }
1723 XmlDataLoader xmlDataLoader = null;
1724 reader.MoveToContent();
1725 if (reader.NodeType == XmlNodeType.Element)
1726 {
1727 depth = reader.Depth;
1728 }
1729 if (reader.NodeType == XmlNodeType.Element)
1730 {
1731 if (reader.LocalName == "diffgram" && reader.NamespaceURI == "urn:schemas-microsoft-com:xml-diffgram-v1")
1732 {
1733 ReadXmlDiffgram(reader);
1734 ReadEndElement(reader);
1735 return XmlReadMode.DiffGram;
1736 }
1737 if (reader.LocalName == "Schema" && reader.NamespaceURI == "urn:schemas-microsoft-com:xml-data")
1738 {
1739 ReadXDRSchema(reader);
1740 return XmlReadMode.ReadSchema;
1741 }
1742 if (reader.LocalName == "schema" && reader.NamespaceURI == "http://www.w3.org/2001/XMLSchema")
1743 {
1745 return XmlReadMode.ReadSchema;
1746 }
1747 if (reader.LocalName == "schema" && reader.NamespaceURI.StartsWith("http://www.w3.org/", StringComparison.Ordinal))
1748 {
1749 throw ExceptionBuilder.DataSetUnsupportedSchema("http://www.w3.org/2001/XMLSchema");
1750 }
1751 XmlElement xmlElement = xmlDocument.CreateElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
1752 if (reader.HasAttributes)
1753 {
1754 int attributeCount = reader.AttributeCount;
1755 for (int i = 0; i < attributeCount; i++)
1756 {
1757 reader.MoveToAttribute(i);
1758 if (reader.NamespaceURI.Equals("http://www.w3.org/2000/xmlns/"))
1759 {
1760 xmlElement.SetAttribute(reader.Name, reader.GetAttribute(i));
1761 continue;
1762 }
1763 XmlAttribute xmlAttribute = xmlElement.SetAttributeNode(reader.LocalName, reader.NamespaceURI);
1764 xmlAttribute.Prefix = reader.Prefix;
1765 xmlAttribute.Value = reader.GetAttribute(i);
1766 }
1767 }
1768 reader.Read();
1769 string value = reader.Value;
1770 while (MoveToElement(reader, depth))
1771 {
1772 if (reader.LocalName == "diffgram" && reader.NamespaceURI == "urn:schemas-microsoft-com:xml-diffgram-v1")
1773 {
1774 ReadXmlDiffgram(reader);
1775 result = XmlReadMode.DiffGram;
1776 }
1777 if (!flag2 && !flag && reader.LocalName == "Schema" && reader.NamespaceURI == "urn:schemas-microsoft-com:xml-data")
1778 {
1779 ReadXDRSchema(reader);
1780 flag2 = true;
1781 isXdr = true;
1782 continue;
1783 }
1784 if (reader.LocalName == "schema" && reader.NamespaceURI == "http://www.w3.org/2001/XMLSchema")
1785 {
1787 flag2 = true;
1788 continue;
1789 }
1790 if (reader.LocalName == "schema" && reader.NamespaceURI.StartsWith("http://www.w3.org/", StringComparison.Ordinal))
1791 {
1792 throw ExceptionBuilder.DataSetUnsupportedSchema("http://www.w3.org/2001/XMLSchema");
1793 }
1794 if (reader.LocalName == "diffgram" && reader.NamespaceURI == "urn:schemas-microsoft-com:xml-diffgram-v1")
1795 {
1796 ReadXmlDiffgram(reader);
1797 flag3 = true;
1798 result = XmlReadMode.DiffGram;
1799 continue;
1800 }
1801 while (!reader.EOF && reader.NodeType == XmlNodeType.Whitespace)
1802 {
1803 reader.Read();
1804 }
1805 if (reader.NodeType != XmlNodeType.Element)
1806 {
1807 continue;
1808 }
1809 flag = true;
1810 if (!flag2 && Tables.Count == 0)
1811 {
1812 XmlNode newChild = xmlDocument.ReadNode(reader);
1813 xmlElement.AppendChild(newChild);
1814 continue;
1815 }
1816 if (xmlDataLoader == null)
1817 {
1818 xmlDataLoader = new XmlDataLoader(this, isXdr, xmlElement, ignoreSchema: false);
1819 }
1820 xmlDataLoader.LoadData(reader);
1821 flag5 = true;
1822 result = (flag2 ? XmlReadMode.ReadSchema : XmlReadMode.IgnoreSchema);
1823 }
1824 ReadEndElement(reader);
1825 bool flag6 = false;
1827 if (!flag2 && Tables.Count == 0 && !xmlElement.HasChildNodes)
1828 {
1829 _fTopLevelTable = true;
1830 flag6 = true;
1831 if (value != null && value.Length > 0)
1832 {
1834 }
1835 }
1836 if (!flag4 && value != null && value.Length > 0)
1837 {
1839 }
1840 xmlDocument.AppendChild(xmlElement);
1841 if (xmlDataLoader == null)
1842 {
1843 xmlDataLoader = new XmlDataLoader(this, isXdr, xmlElement, ignoreSchema: false);
1844 }
1845 if (!flag4 && !flag5)
1846 {
1847 XmlElement documentElement = xmlDocument.DocumentElement;
1848 if (documentElement.ChildNodes.Count == 0 || (documentElement.ChildNodes.Count == 1 && documentElement.FirstChild.GetType() == typeof(XmlText)))
1849 {
1851 if (DataSetName != documentElement.Name && _namespaceURI != documentElement.NamespaceURI && Tables.Contains(documentElement.Name, (documentElement.NamespaceURI.Length == 0) ? null : documentElement.NamespaceURI, checkProperty: false, caseSensitive: true))
1852 {
1853 _fTopLevelTable = true;
1854 }
1855 try
1856 {
1857 xmlDataLoader.LoadData(xmlDocument);
1858 }
1859 finally
1860 {
1862 }
1863 }
1864 }
1865 if (!flag3)
1866 {
1867 if (!flag2 && Tables.Count == 0)
1868 {
1869 InferSchema(xmlDocument, null, XmlReadMode.Auto);
1870 result = XmlReadMode.InferSchema;
1872 try
1873 {
1874 xmlDataLoader.LoadData(xmlDocument);
1875 }
1876 finally
1877 {
1879 }
1880 }
1881 if (flag6)
1882 {
1884 }
1885 }
1886 }
1887 return result;
1888 }
1889 finally
1890 {
1891 }
1892 }
1893 finally
1894 {
1895 disposable?.Dispose();
1896 DataCommonEventSource.Log.ExitScope(scopeId);
1897 }
1898 }
DataTableCollection Tables
Definition DataSet.cs:396
string _namespaceURI
Definition DataSet.cs:67
void ReadXDRSchema(XmlReader reader)
Definition DataSet.cs:1532
void ReadXmlDiffgram(XmlReader reader)
Definition DataSet.cs:1985
void ReadXSDSchema(XmlReader reader, bool denyResolving)
Definition DataSet.cs:1500
void ReadEndElement(XmlReader reader)
Definition DataSet.cs:1483
bool MoveToElement(XmlReader reader, int depth)
Definition DataSet.cs:1466
string? GetAttribute(string name)
bool MoveToAttribute(string name)
virtual bool HasAttributes
Definition XmlReader.cs:124
virtual XmlNodeType MoveToContent()
Definition XmlReader.cs:604
XmlNodeType NodeType
Definition XmlReader.cs:62
virtual string Name
Definition XmlReader.cs:65

References System.Data.DataSet._fTopLevelTable, System.Data.DataSet._namespaceURI, System.Xml.XmlReader.AttributeCount, System.Data.DataTableCollection.Contains(), System.Data.InternalDataCollectionBase.Count, System.Collections.Generic.Dictionary< TKey, TValue >.Count, System.Data.DataSet.DataSetName, System.Data.ExceptionBuilder.DataSetUnsupportedSchema(), System.Xml.XmlReader.Depth, System.Runtime.Serialization.Dictionary, System.Data.TypeLimiter.EnterRestrictedScope(), System.Xml.XmlReader.EOF, System.Xml.XmlReader.GetAttribute(), System.Xml.XmlReader.HasAttributes, System.Data.InferSchema, System.Xml.XmlReader.LocalName, System.Data.DataCommonEventSource.Log, System.Xml.XmlReader.MoveToAttribute(), System.Xml.XmlReader.MoveToContent(), System.Data.DataSet.MoveToElement(), System.Xml.XmlReader.Name, System.Xml.XmlReader.NamespaceURI, System.Xml.XmlReader.NodeType, System.Data.DataSet.ObjectID, System.Xml.XmlReader.Prefix, System.Xml.XmlReader.Read(), System.Data.DataSet.ReadEndElement(), System.Data.DataSet.ReadXDRSchema(), System.Data.DataSet.ReadXmlDiffgram(), System.Data.DataSet.ReadXSDSchema(), System.Data.DataSet.Tables, System.value, and System.Xml.XmlReader.Value.