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

◆ GenerateColumn()

void System.Data.NewDiffgramGen.GenerateColumn ( DataRow row,
DataColumn col,
DataRowVersion version )
inlineprivate

Definition at line 292 of file NewDiffgramGen.cs.

293 {
294 string text = null;
295 text = col.GetColumnValueAsString(row, version);
296 if (text == null)
297 {
298 if (col.ColumnMapping == MappingType.SimpleContent)
299 {
300 _xmlw.WriteAttributeString("xsi", "nil", "http://www.w3.org/2001/XMLSchema-instance", "true");
301 }
302 return;
303 }
304 string prefix = ((col.Namespace.Length != 0) ? col.Prefix : string.Empty);
305 switch (col.ColumnMapping)
306 {
307 case MappingType.Attribute:
308 _xmlw.WriteAttributeString(prefix, col.EncodedColumnName, col.Namespace, text);
309 break;
310 case MappingType.Hidden:
311 _xmlw.WriteAttributeString("msdata", "hidden" + col.EncodedColumnName, "urn:schemas-microsoft-com:xml-msdata", text);
312 break;
313 case MappingType.SimpleContent:
315 break;
316 case MappingType.Element:
317 {
318 bool flag = true;
319 object obj = row[col, version];
320 if (!col.IsCustomType || !col.IsValueCustomTypeInstance(obj) || typeof(IXmlSerializable).IsAssignableFrom(obj.GetType()))
321 {
322 _xmlw.WriteStartElement(prefix, col.EncodedColumnName, col.Namespace);
323 flag = false;
324 }
325 Type type = obj.GetType();
326 if (!col.IsCustomType)
327 {
328 if ((type == typeof(char) || type == typeof(string)) && XmlDataTreeWriter.PreserveSpace(text))
329 {
330 _xmlw.WriteAttributeString("xml", "space", "http://www.w3.org/XML/1998/namespace", "preserve");
331 }
333 }
334 else if (obj != DBNull.Value && (!col.ImplementsINullable || !DataStorage.IsObjectSqlNull(obj)))
335 {
336 if (col.IsValueCustomTypeInstance(obj))
337 {
338 if (!flag && obj.GetType() != col.DataType)
339 {
340 _xmlw.WriteAttributeString("msdata", "InstanceType", "urn:schemas-microsoft-com:xml-msdata", DataStorage.GetQualifiedName(type));
341 }
342 if (!flag)
343 {
344 col.ConvertObjectToXml(obj, _xmlw, null);
345 }
346 else
347 {
348 if (obj.GetType() != col.DataType)
349 {
350 throw ExceptionBuilder.PolymorphismNotSupported(type.AssemblyQualifiedName);
351 }
352 XmlRootAttribute xmlRootAttribute = new XmlRootAttribute(col.EncodedColumnName);
354 col.ConvertObjectToXml(obj, _xmlw, xmlRootAttribute);
355 }
356 }
357 else
358 {
359 if (type == typeof(Type) || type == typeof(Guid) || type == typeof(char) || DataStorage.IsSqlType(type))
360 {
361 _xmlw.WriteAttributeString("msdata", "InstanceType", "urn:schemas-microsoft-com:xml-msdata", type.FullName);
362 }
363 else if (obj is Type)
364 {
365 _xmlw.WriteAttributeString("msdata", "InstanceType", "urn:schemas-microsoft-com:xml-msdata", "Type");
366 }
367 else
368 {
369 string value = "xs:" + XmlTreeGen.XmlDataTypeName(type);
370 _xmlw.WriteAttributeString("xsi", "type", "http://www.w3.org/2001/XMLSchema-instance", value);
371 _xmlw.WriteAttributeString("xs", "xmlns", "http://www.w3.org/2001/XMLSchema", value);
372 }
374 {
375 _xmlw.WriteString(col.ConvertObjectToXml(obj));
376 }
377 else
378 {
379 col.ConvertObjectToXml(obj, _xmlw, null);
380 }
381 }
382 }
383 if (!flag)
384 {
386 }
387 break;
388 }
389 }
390 }
static string GetQualifiedName(Type type)
static bool IsObjectSqlNull(object value)
static bool IsSqlType(StorageType storageType)
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.NewDiffgramGen._xmlw, System.Xml.Dictionary, System.Data.Common.DataStorage.GetQualifiedName(), System.Type.GetType(), System.Data.Common.DataStorage.IsObjectSqlNull(), System.Data.Common.DataStorage.IsSqlType(), System.obj, System.Data.ExceptionBuilder.PolymorphismNotSupported(), System.prefix, System.Data.XmlDataTreeWriter.PreserveSpace(), System.text, System.type, System.DBNull.Value, System.value, System.Xml.XmlWriter.WriteAttributeString(), System.Xml.XmlWriter.WriteEndElement(), System.Xml.XmlWriter.WriteStartElement(), System.Xml.XmlWriter.WriteString(), and System.Data.XmlTreeGen.XmlDataTypeName().

Referenced by System.Data.NewDiffgramGen.GenerateRow().