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

◆ ReadOldRowData()

int System.Data.XMLDiffLoader.ReadOldRowData ( DataSet ds,
ref DataTable table,
ref int pos,
XmlReader row )
inlineprivate

Definition at line 259 of file XMLDiffLoader.cs.

260 {
261 if (ds != null)
262 {
263 table = ds.Tables.GetTable(XmlConvert.DecodeName(row.LocalName), row.NamespaceURI);
264 }
265 else
266 {
267 table = GetTable(XmlConvert.DecodeName(row.LocalName), row.NamespaceURI);
268 }
269 if (table == null)
270 {
271 row.Skip();
272 return -1;
273 }
274 int depth = row.Depth;
275 string text = null;
276 text = row.GetAttribute("rowOrder", "urn:schemas-microsoft-com:xml-msdata");
277 if (!string.IsNullOrEmpty(text))
278 {
279 pos = (int)Convert.ChangeType(text, typeof(int), null);
280 }
281 int num = table.NewRecord();
282 foreach (DataColumn column in table.Columns)
283 {
284 column[num] = DBNull.Value;
285 }
286 foreach (DataColumn column2 in table.Columns)
287 {
288 if (column2.ColumnMapping != MappingType.Element && column2.ColumnMapping != MappingType.SimpleContent)
289 {
290 text = ((column2.ColumnMapping != MappingType.Hidden) ? row.GetAttribute(column2.EncodedColumnName, column2.Namespace) : row.GetAttribute("hidden" + column2.EncodedColumnName, "urn:schemas-microsoft-com:xml-msdata"));
291 if (text != null)
292 {
293 column2[num] = column2.ConvertXmlToObject(text);
294 }
295 }
296 }
297 row.Read();
299 int depth2 = row.Depth;
300 if (depth2 <= depth)
301 {
302 if (depth2 == depth && row.NodeType == XmlNodeType.EndElement)
303 {
304 row.Read();
306 }
307 return num;
308 }
309 if (table.XmlText != null)
310 {
311 DataColumn xmlText = table.XmlText;
312 xmlText[num] = xmlText.ConvertXmlToObject(row.ReadString());
313 }
314 else
315 {
316 while (row.Depth > depth)
317 {
318 string text2 = XmlConvert.DecodeName(row.LocalName);
319 string namespaceURI = row.NamespaceURI;
320 DataColumn dataColumn3 = table.Columns[text2, namespaceURI];
321 if (dataColumn3 == null)
322 {
323 while (row.NodeType != XmlNodeType.EndElement && row.LocalName != text2 && row.NamespaceURI != namespaceURI)
324 {
325 row.Read();
326 }
327 row.Read();
328 continue;
329 }
330 if (dataColumn3.IsCustomType)
331 {
332 bool flag = dataColumn3.DataType == typeof(object) || row.GetAttribute("InstanceType", "urn:schemas-microsoft-com:xml-msdata") != null || row.GetAttribute("type", "http://www.w3.org/2001/XMLSchema-instance") != null;
333 bool flag2 = false;
334 if (dataColumn3.Table.DataSet != null && dataColumn3.Table.DataSet._udtIsWrapped)
335 {
336 row.Read();
337 flag2 = true;
338 }
340 if (!flag && !dataColumn3.ImplementsIXMLSerializable)
341 {
342 if (flag2)
343 {
344 xmlRootAttribute = new XmlRootAttribute(row.LocalName);
345 xmlRootAttribute.Namespace = row.NamespaceURI;
346 }
347 else
348 {
349 xmlRootAttribute = new XmlRootAttribute(dataColumn3.EncodedColumnName);
351 }
352 }
353 dataColumn3[num] = dataColumn3.ConvertXmlToObject(row, xmlRootAttribute);
354 if (flag2)
355 {
356 row.Read();
357 }
358 continue;
359 }
360 int depth3 = row.Depth;
361 row.Read();
362 if (row.Depth > depth3)
363 {
364 if (row.NodeType == XmlNodeType.Text || row.NodeType == XmlNodeType.Whitespace || row.NodeType == XmlNodeType.SignificantWhitespace)
365 {
366 string s = row.ReadString();
367 dataColumn3[num] = dataColumn3.ConvertXmlToObject(s);
368 row.Read();
369 }
370 }
371 else if (dataColumn3.DataType == typeof(string))
372 {
373 dataColumn3[num] = string.Empty;
374 }
375 }
376 }
377 row.Read();
379 return num;
380 }
DataTable GetTable(string tableName, string ns)
void SkipWhitespaces(XmlReader reader)
static ? string DecodeName(string? name)
Definition XmlConvert.cs:55

References System.Convert.ChangeType(), System.Data.DataColumn.ConvertXmlToObject(), System.Xml.XmlConvert.DecodeName(), System.Xml.Dictionary, System.Data.XMLDiffLoader.GetTable(), System.s, System.Data.XMLDiffLoader.SkipWhitespaces(), System.text, and System.DBNull.Value.

Referenced by System.Data.XMLDiffLoader.ProcessDiffs(), and System.Data.XMLDiffLoader.ProcessDiffs().