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

◆ XmlDataRowWriter()

void System.Data.XmlDataTreeWriter.XmlDataRowWriter ( DataRow row,
string encodedTableName )
inlinepackage

Definition at line 257 of file XmlDataTreeWriter.cs.

258 {
259 string prefix = ((row.Table.Namespace.Length == 0) ? "" : row.Table.Prefix);
261 if (_isDiffgram)
262 {
263 _xmlw.WriteAttributeString("diffgr", "id", "urn:schemas-microsoft-com:xml-diffgram-v1", row.Table.TableName + row.rowID.ToString(CultureInfo.InvariantCulture));
264 _xmlw.WriteAttributeString("msdata", "rowOrder", "urn:schemas-microsoft-com:xml-msdata", _rowsOrder[row].ToString());
265 if (row.RowState == DataRowState.Added)
266 {
267 _xmlw.WriteAttributeString("diffgr", "hasChanges", "urn:schemas-microsoft-com:xml-diffgram-v1", "inserted");
268 }
269 if (row.RowState == DataRowState.Modified)
270 {
271 _xmlw.WriteAttributeString("diffgr", "hasChanges", "urn:schemas-microsoft-com:xml-diffgram-v1", "modified");
272 }
273 if (RowHasErrors(row))
274 {
275 _xmlw.WriteAttributeString("diffgr", "hasErrors", "urn:schemas-microsoft-com:xml-diffgram-v1", "true");
276 }
277 }
278 foreach (DataColumn column in row.Table.Columns)
279 {
280 if (column._columnMapping == MappingType.Attribute)
281 {
282 object obj = row[column];
283 string prefix2 = ((column.Namespace.Length == 0) ? "" : column.Prefix);
284 if (obj != DBNull.Value && (!column.ImplementsINullable || !DataStorage.IsObjectSqlNull(obj)))
285 {
286 XmlTreeGen.ValidateColumnMapping(column.DataType);
287 _xmlw.WriteAttributeString(prefix2, column.EncodedColumnName, column.Namespace, column.ConvertObjectToXml(obj));
288 }
289 }
290 if (_isDiffgram && column._columnMapping == MappingType.Hidden)
291 {
292 object obj = row[column];
293 if (obj != DBNull.Value && (!column.ImplementsINullable || !DataStorage.IsObjectSqlNull(obj)))
294 {
295 XmlTreeGen.ValidateColumnMapping(column.DataType);
296 _xmlw.WriteAttributeString("msdata", "hidden" + column.EncodedColumnName, "urn:schemas-microsoft-com:xml-msdata", column.ConvertObjectToXml(obj));
297 }
298 }
299 }
300 foreach (DataColumn column2 in row.Table.Columns)
301 {
302 if (column2._columnMapping == MappingType.Hidden)
303 {
304 continue;
305 }
306 object obj = row[column2];
307 string prefix3 = ((column2.Namespace.Length == 0) ? "" : column2.Prefix);
308 bool flag = true;
309 if ((obj == DBNull.Value || (column2.ImplementsINullable && DataStorage.IsObjectSqlNull(obj))) && column2.ColumnMapping == MappingType.SimpleContent)
310 {
311 _xmlw.WriteAttributeString("xsi", "nil", "http://www.w3.org/2001/XMLSchema-instance", "true");
312 }
313 if (obj == DBNull.Value || (column2.ImplementsINullable && DataStorage.IsObjectSqlNull(obj)) || column2._columnMapping == MappingType.Attribute)
314 {
315 continue;
316 }
317 if (column2._columnMapping != MappingType.SimpleContent && (!column2.IsCustomType || !column2.IsValueCustomTypeInstance(obj) || typeof(IXmlSerializable).IsAssignableFrom(obj.GetType())))
318 {
319 _xmlw.WriteStartElement(prefix3, column2.EncodedColumnName, column2.Namespace);
320 flag = false;
321 }
322 Type type = obj.GetType();
323 if (!column2.IsCustomType)
324 {
325 if ((type == typeof(char) || type == typeof(string)) && PreserveSpace(obj))
326 {
327 _xmlw.WriteAttributeString("xml", "space", "http://www.w3.org/XML/1998/namespace", "preserve");
328 }
329 _xmlw.WriteString(column2.ConvertObjectToXml(obj));
330 }
331 else if (column2.IsValueCustomTypeInstance(obj))
332 {
333 if (!flag && type != column2.DataType)
334 {
335 _xmlw.WriteAttributeString("msdata", "InstanceType", "urn:schemas-microsoft-com:xml-msdata", DataStorage.GetQualifiedName(type));
336 }
337 if (!flag)
338 {
339 column2.ConvertObjectToXml(obj, _xmlw, null);
340 }
341 else
342 {
343 if (obj.GetType() != column2.DataType)
344 {
345 throw ExceptionBuilder.PolymorphismNotSupported(type.AssemblyQualifiedName);
346 }
349 column2.ConvertObjectToXml(obj, _xmlw, xmlRootAttribute);
350 }
351 }
352 else
353 {
354 if (type == typeof(Type) || type == typeof(Guid) || type == typeof(char) || DataStorage.IsSqlType(type))
355 {
356 _xmlw.WriteAttributeString("msdata", "InstanceType", "urn:schemas-microsoft-com:xml-msdata", type.FullName);
357 }
358 else if (obj is Type)
359 {
360 _xmlw.WriteAttributeString("msdata", "InstanceType", "urn:schemas-microsoft-com:xml-msdata", "Type");
361 }
362 else
363 {
364 string value = "xs:" + XmlTreeGen.XmlDataTypeName(type);
365 _xmlw.WriteAttributeString("xsi", "type", "http://www.w3.org/2001/XMLSchema-instance", value);
366 _xmlw.WriteAttributeString("xs", "xmlns", "http://www.w3.org/2001/XMLSchema", value);
367 }
369 {
370 _xmlw.WriteString(column2.ConvertObjectToXml(obj));
371 }
372 else
373 {
374 column2.ConvertObjectToXml(obj, _xmlw, null);
375 }
376 }
377 if (column2._columnMapping != MappingType.SimpleContent && !flag)
378 {
380 }
381 }
382 if (_ds != null)
383 {
384 foreach (DataRelation nestedChildRelation in GetNestedChildRelations(row))
385 {
386 DataRow[] childRows = row.GetChildRows(nestedChildRelation);
387 foreach (DataRow row2 in childRows)
388 {
389 XmlDataRowWriter(row2, nestedChildRelation.ChildTable.EncodedTableName);
390 }
391 }
392 }
394 }
static string GetQualifiedName(Type type)
static bool IsObjectSqlNull(object value)
static bool IsSqlType(StorageType storageType)
static bool PreserveSpace(object value)
void XmlDataRowWriter(DataRow row, string encodedTableName)
static bool RowHasErrors(DataRow row)
ArrayList GetNestedChildRelations(DataRow row)
static CultureInfo InvariantCulture
void WriteString(string? text)
void WriteAttributeString(string localName, string? ns, string? value)
Definition XmlWriter.cs:46
void WriteStartElement(string localName, string? ns)
Definition XmlWriter.cs:30

References System.Data.XmlDataTreeWriter._ds, System.Data.XmlDataTreeWriter._isDiffgram, System.Data.XmlDataTreeWriter._rowsOrder, System.Data.XmlDataTreeWriter._xmlw, System.Data.DataTable.Columns, System.Xml.Dictionary, System.Data.DataRow.GetChildRows(), System.Data.XmlDataTreeWriter.GetNestedChildRelations(), System.Data.Common.DataStorage.GetQualifiedName(), System.Type.GetType(), System.Globalization.CultureInfo.InvariantCulture, System.Data.Common.DataStorage.IsObjectSqlNull(), System.Data.Common.DataStorage.IsSqlType(), System.obj, System.Data.ExceptionBuilder.PolymorphismNotSupported(), System.prefix, System.Data.XmlDataTreeWriter.PreserveSpace(), System.Data.XmlDataTreeWriter.RowHasErrors(), System.Data.DataColumn.Table, System.ToString, System.type, System.Data.XmlTreeGen.ValidateColumnMapping(), System.DBNull.Value, System.value, System.Xml.XmlWriter.WriteAttributeString(), System.Xml.XmlWriter.WriteEndElement(), System.Xml.XmlWriter.WriteStartElement(), System.Xml.XmlWriter.WriteString(), System.Data.XmlDataTreeWriter.XmlDataRowWriter(), and System.Data.XmlTreeGen.XmlDataTypeName().

Referenced by System.Data.XmlDataTreeWriter.Save(), System.Data.XmlDataTreeWriter.SaveDiffgramData(), and System.Data.XmlDataTreeWriter.XmlDataRowWriter().