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

◆ WriteTypedPrimitive()

void System.Xml.Serialization.XmlSerializationWriter.WriteTypedPrimitive ( string? name,
string? ns,
object o,
bool xsiType )
inlineprotected

Definition at line 289 of file XmlSerializationWriter.cs.

290 {
291 string text = null;
292 string ns2 = "http://www.w3.org/2001/XMLSchema";
293 bool flag = true;
294 bool flag2 = false;
295 Type type = o.GetType();
296 bool flag3 = false;
297 string text2;
298 switch (Type.GetTypeCode(type))
299 {
300 case TypeCode.String:
301 text = (string)o;
302 text2 = "string";
303 flag = false;
304 break;
305 case TypeCode.Int32:
306 text = XmlConvert.ToString((int)o);
307 text2 = "int";
308 break;
309 case TypeCode.Boolean:
310 text = XmlConvert.ToString((bool)o);
311 text2 = "boolean";
312 break;
313 case TypeCode.Int16:
314 text = XmlConvert.ToString((short)o);
315 text2 = "short";
316 break;
317 case TypeCode.Int64:
318 text = XmlConvert.ToString((long)o);
319 text2 = "long";
320 break;
321 case TypeCode.Single:
322 text = XmlConvert.ToString((float)o);
323 text2 = "float";
324 break;
325 case TypeCode.Double:
326 text = XmlConvert.ToString((double)o);
327 text2 = "double";
328 break;
329 case TypeCode.Decimal:
330 text = XmlConvert.ToString((decimal)o);
331 text2 = "decimal";
332 break;
333 case TypeCode.DateTime:
335 text2 = "dateTime";
336 break;
337 case TypeCode.Char:
338 text = FromChar((char)o);
339 text2 = "char";
340 ns2 = "http://microsoft.com/wsdl/types/";
341 break;
342 case TypeCode.Byte:
343 text = XmlConvert.ToString((byte)o);
344 text2 = "unsignedByte";
345 break;
346 case TypeCode.SByte:
347 text = XmlConvert.ToString((sbyte)o);
348 text2 = "byte";
349 break;
350 case TypeCode.UInt16:
351 text = XmlConvert.ToString((ushort)o);
352 text2 = "unsignedShort";
353 break;
354 case TypeCode.UInt32:
355 text = XmlConvert.ToString((uint)o);
356 text2 = "unsignedInt";
357 break;
358 case TypeCode.UInt64:
359 text = XmlConvert.ToString((ulong)o);
360 text2 = "unsignedLong";
361 break;
362 default:
363 if (type == typeof(XmlQualifiedName))
364 {
365 text2 = "QName";
366 flag3 = true;
367 if (name == null)
368 {
370 }
371 else
372 {
373 _w.WriteStartElement(name, ns);
374 }
375 text = FromXmlQualifiedName((XmlQualifiedName)o, ignoreEmpty: false);
376 break;
377 }
378 if (type == typeof(byte[]))
379 {
380 text = string.Empty;
381 flag2 = true;
382 text2 = "base64Binary";
383 break;
384 }
385 if (type == typeof(Guid))
386 {
387 text = XmlConvert.ToString((Guid)o);
388 text2 = "guid";
389 ns2 = "http://microsoft.com/wsdl/types/";
390 break;
391 }
392 if (type == typeof(TimeSpan))
393 {
394 text = XmlConvert.ToString((TimeSpan)o);
395 text2 = "TimeSpan";
396 ns2 = "http://microsoft.com/wsdl/types/";
397 break;
398 }
399 if (type == typeof(DateTimeOffset))
400 {
401 text = XmlConvert.ToString((DateTimeOffset)o);
402 text2 = "dateTimeOffset";
403 ns2 = "http://microsoft.com/wsdl/types/";
404 break;
405 }
406 if (typeof(XmlNode[]).IsAssignableFrom(type))
407 {
408 if (name == null)
409 {
410 _w.WriteStartElement("anyType", "http://www.w3.org/2001/XMLSchema");
411 }
412 else
413 {
414 _w.WriteStartElement(name, ns);
415 }
416 XmlNode[] array = (XmlNode[])o;
417 for (int i = 0; i < array.Length; i++)
418 {
419 if (array[i] != null)
420 {
421 array[i].WriteTo(_w);
422 }
423 }
425 return;
426 }
428 }
429 if (!flag3)
430 {
431 if (name == null)
432 {
434 }
435 else
436 {
437 _w.WriteStartElement(name, ns);
438 }
439 }
440 if (xsiType)
441 {
443 }
444 if (text == null)
445 {
446 _w.WriteAttributeString("nil", "http://www.w3.org/2001/XMLSchema-instance", "true");
447 }
448 else if (flag2)
449 {
450 XmlCustomFormatter.WriteArrayBase64(_w, (byte[])o, 0, ((byte[])o).Length);
451 }
452 else if (flag)
453 {
455 }
456 else
457 {
459 }
461 }
string? FromXmlQualifiedName(XmlQualifiedName? xmlQualifiedName)
void WriteString(string? text)
void WriteRaw(char[] buffer, int index, int count)
void WriteAttributeString(string localName, string? ns, string? value)
Definition XmlWriter.cs:46
void WriteStartElement(string localName, string? ns)
Definition XmlWriter.cs:30

References System.Xml.Serialization.XmlSerializationWriter._w, System.array, System.Xml.Serialization.XmlSerializationWriter.CreateUnknownTypeException(), System.Xml.Dictionary, System.Xml.Serialization.XmlSerializationWriter.FromChar(), System.Xml.Serialization.XmlSerializationWriter.FromDateTime(), System.Xml.Serialization.XmlSerializationWriter.FromXmlQualifiedName(), System.Type.GetTypeCode(), System.Xml.Schema.Length, System.text, System.Xml.XmlConvert.ToString(), System.type, System.Xml.Serialization.XmlCustomFormatter.WriteArrayBase64(), System.Xml.XmlWriter.WriteAttributeString(), System.Xml.XmlWriter.WriteEndElement(), System.Xml.XmlWriter.WriteRaw(), System.Xml.XmlWriter.WriteStartElement(), System.Xml.XmlWriter.WriteString(), and System.Xml.Serialization.XmlSerializationWriter.WriteXsiType().

Referenced by System.Xml.Serialization.XmlSerializationWriter.WritePotentiallyReferencingElement(), and System.Xml.Serialization.ReflectionXmlSerializationWriter.WriteStructMethod().