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

◆ ReadXml() [9/11]

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

Definition at line 2105 of file DataSet.cs.

2106 {
2107 IDisposable disposable = null;
2108 long scopeId = DataCommonEventSource.Log.EnterScope("<ds.DataSet.ReadXml|INFO> {0}, mode={1}, denyResolving={2}", ObjectID, mode, denyResolving);
2109 try
2110 {
2111 disposable = TypeLimiter.EnterRestrictedScope(this);
2112 XmlReadMode result = mode;
2113 if (reader == null)
2114 {
2115 return result;
2116 }
2117 if (mode == XmlReadMode.Auto)
2118 {
2119 return ReadXml(reader);
2120 }
2121 DataTable.DSRowDiffIdUsageSection dSRowDiffIdUsageSection = default(DataTable.DSRowDiffIdUsageSection);
2122 try
2123 {
2124 bool flag = false;
2125 bool flag2 = false;
2126 bool isXdr = false;
2127 int depth = -1;
2128 dSRowDiffIdUsageSection.Prepare(this);
2129 if (reader is XmlTextReader)
2130 {
2131 ((XmlTextReader)reader).WhitespaceHandling = WhitespaceHandling.Significant;
2132 }
2134 if (mode != XmlReadMode.Fragment && reader.NodeType == XmlNodeType.Element)
2135 {
2136 depth = reader.Depth;
2137 }
2138 reader.MoveToContent();
2139 XmlDataLoader xmlDataLoader = null;
2140 if (reader.NodeType == XmlNodeType.Element)
2141 {
2142 XmlElement xmlElement = null;
2143 if (mode == XmlReadMode.Fragment)
2144 {
2145 xmlDocument.AppendChild(xmlDocument.CreateElement("ds_sqlXmlWraPPeR"));
2146 xmlElement = xmlDocument.DocumentElement;
2147 }
2148 else
2149 {
2150 if (reader.LocalName == "diffgram" && reader.NamespaceURI == "urn:schemas-microsoft-com:xml-diffgram-v1")
2151 {
2152 if (mode == XmlReadMode.DiffGram || mode == XmlReadMode.IgnoreSchema)
2153 {
2154 ReadXmlDiffgram(reader);
2155 ReadEndElement(reader);
2156 }
2157 else
2158 {
2159 reader.Skip();
2160 }
2161 return result;
2162 }
2163 if (reader.LocalName == "Schema" && reader.NamespaceURI == "urn:schemas-microsoft-com:xml-data")
2164 {
2165 if (mode != XmlReadMode.IgnoreSchema && mode != XmlReadMode.InferSchema && mode != XmlReadMode.InferTypedSchema)
2166 {
2167 ReadXDRSchema(reader);
2168 }
2169 else
2170 {
2171 reader.Skip();
2172 }
2173 return result;
2174 }
2175 if (reader.LocalName == "schema" && reader.NamespaceURI == "http://www.w3.org/2001/XMLSchema")
2176 {
2177 if (mode != XmlReadMode.IgnoreSchema && mode != XmlReadMode.InferSchema && mode != XmlReadMode.InferTypedSchema)
2178 {
2180 }
2181 else
2182 {
2183 reader.Skip();
2184 }
2185 return result;
2186 }
2187 if (reader.LocalName == "schema" && reader.NamespaceURI.StartsWith("http://www.w3.org/", StringComparison.Ordinal))
2188 {
2189 throw ExceptionBuilder.DataSetUnsupportedSchema("http://www.w3.org/2001/XMLSchema");
2190 }
2191 xmlElement = xmlDocument.CreateElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
2192 if (reader.HasAttributes)
2193 {
2194 int attributeCount = reader.AttributeCount;
2195 for (int i = 0; i < attributeCount; i++)
2196 {
2197 reader.MoveToAttribute(i);
2198 if (reader.NamespaceURI.Equals("http://www.w3.org/2000/xmlns/"))
2199 {
2200 xmlElement.SetAttribute(reader.Name, reader.GetAttribute(i));
2201 continue;
2202 }
2203 XmlAttribute xmlAttribute = xmlElement.SetAttributeNode(reader.LocalName, reader.NamespaceURI);
2204 xmlAttribute.Prefix = reader.Prefix;
2205 xmlAttribute.Value = reader.GetAttribute(i);
2206 }
2207 }
2208 reader.Read();
2209 }
2210 while (MoveToElement(reader, depth))
2211 {
2212 if (reader.LocalName == "Schema" && reader.NamespaceURI == "urn:schemas-microsoft-com:xml-data")
2213 {
2214 if (!flag && !flag2 && mode != XmlReadMode.IgnoreSchema && mode != XmlReadMode.InferSchema && mode != XmlReadMode.InferTypedSchema)
2215 {
2216 ReadXDRSchema(reader);
2217 flag = true;
2218 isXdr = true;
2219 }
2220 else
2221 {
2222 reader.Skip();
2223 }
2224 continue;
2225 }
2226 if (reader.LocalName == "schema" && reader.NamespaceURI == "http://www.w3.org/2001/XMLSchema")
2227 {
2228 if (mode != XmlReadMode.IgnoreSchema && mode != XmlReadMode.InferSchema && mode != XmlReadMode.InferTypedSchema)
2229 {
2231 flag = true;
2232 }
2233 else
2234 {
2235 reader.Skip();
2236 }
2237 continue;
2238 }
2239 if (reader.LocalName == "diffgram" && reader.NamespaceURI == "urn:schemas-microsoft-com:xml-diffgram-v1")
2240 {
2241 if (mode == XmlReadMode.DiffGram || mode == XmlReadMode.IgnoreSchema)
2242 {
2243 ReadXmlDiffgram(reader);
2244 result = XmlReadMode.DiffGram;
2245 }
2246 else
2247 {
2248 reader.Skip();
2249 }
2250 continue;
2251 }
2252 if (reader.LocalName == "schema" && reader.NamespaceURI.StartsWith("http://www.w3.org/", StringComparison.Ordinal))
2253 {
2254 throw ExceptionBuilder.DataSetUnsupportedSchema("http://www.w3.org/2001/XMLSchema");
2255 }
2256 if (mode == XmlReadMode.DiffGram)
2257 {
2258 reader.Skip();
2259 continue;
2260 }
2261 flag2 = true;
2262 if (mode == XmlReadMode.InferSchema || mode == XmlReadMode.InferTypedSchema)
2263 {
2264 XmlNode newChild = xmlDocument.ReadNode(reader);
2265 xmlElement.AppendChild(newChild);
2266 continue;
2267 }
2268 if (xmlDataLoader == null)
2269 {
2270 xmlDataLoader = new XmlDataLoader(this, isXdr, xmlElement, mode == XmlReadMode.IgnoreSchema);
2271 }
2272 xmlDataLoader.LoadData(reader);
2273 }
2274 ReadEndElement(reader);
2275 xmlDocument.AppendChild(xmlElement);
2276 if (xmlDataLoader == null)
2277 {
2278 xmlDataLoader = new XmlDataLoader(this, isXdr, mode == XmlReadMode.IgnoreSchema);
2279 }
2280 switch (mode)
2281 {
2282 case XmlReadMode.DiffGram:
2283 return result;
2284 case XmlReadMode.InferSchema:
2285 case XmlReadMode.InferTypedSchema:
2286 InferSchema(xmlDocument, null, mode);
2287 result = XmlReadMode.InferSchema;
2289 try
2290 {
2291 xmlDataLoader.LoadData(xmlDocument);
2292 }
2293 finally
2294 {
2296 }
2297 break;
2298 }
2299 }
2300 return result;
2301 }
2302 finally
2303 {
2304 }
2305 }
2306 finally
2307 {
2308 disposable?.Dispose();
2309 DataCommonEventSource.Log.ExitScope(scopeId);
2310 }
2311 }
XmlReadMode ReadXml(XmlReader? reader)
Definition DataSet.cs:1685
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)
virtual void Skip()
Definition XmlReader.cs:532
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.Xml.XmlReader.AttributeCount, System.Data.ExceptionBuilder.DataSetUnsupportedSchema(), System.Xml.XmlReader.Depth, System.Runtime.Serialization.Dictionary, System.Data.TypeLimiter.EnterRestrictedScope(), 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.ReadXml(), System.Data.DataSet.ReadXmlDiffgram(), System.Data.DataSet.ReadXSDSchema(), and System.Xml.XmlReader.Skip().