private void SerializePrimitive(XmlWriter xmlWriter, object o, XmlSerializerNamespaces namespaces) { XmlSerializationPrimitiveWriter writer = new XmlSerializationPrimitiveWriter(); writer.Init(xmlWriter, namespaces, null, null, null); switch (_primitiveType.GetTypeCode()) { case TypeCode.String: writer.Write_string(o); break; case TypeCode.Int32: writer.Write_int(o); break; case TypeCode.Boolean: writer.Write_boolean(o); break; case TypeCode.Int16: writer.Write_short(o); break; case TypeCode.Int64: writer.Write_long(o); break; case TypeCode.Single: writer.Write_float(o); break; case TypeCode.Double: writer.Write_double(o); break; case TypeCode.Decimal: writer.Write_decimal(o); break; case TypeCode.DateTime: writer.Write_dateTime(o); break; case TypeCode.Char: writer.Write_char(o); break; case TypeCode.Byte: writer.Write_unsignedByte(o); break; case TypeCode.SByte: writer.Write_byte(o); break; case TypeCode.UInt16: writer.Write_unsignedShort(o); break; case TypeCode.UInt32: writer.Write_unsignedInt(o); break; case TypeCode.UInt64: writer.Write_unsignedLong(o); break; default: if (_primitiveType == typeof(XmlQualifiedName)) { writer.Write_QName(o); } else if (_primitiveType == typeof(byte[])) { writer.Write_base64Binary(o); } else if (_primitiveType == typeof(Guid)) { writer.Write_guid(o); } else if (_primitiveType == typeof(TimeSpan)) { writer.Write_TimeSpan(o); } else { throw new InvalidOperationException(SR.Format(SR.XmlUnxpectedType, _primitiveType.FullName)); } break; } }
void SerializePrimitive(XmlWriter xmlWriter, object o, XmlSerializerNamespaces namespaces) { XmlSerializationPrimitiveWriter writer = new XmlSerializationPrimitiveWriter(); writer.Init(xmlWriter, namespaces, null, null, null); switch (Type.GetTypeCode(primitiveType)) { case TypeCode.String: writer.Write_string(o); break; case TypeCode.Int32: writer.Write_int(o); break; case TypeCode.Boolean: writer.Write_boolean(o); break; case TypeCode.Int16: writer.Write_short(o); break; case TypeCode.Int64: writer.Write_long(o); break; case TypeCode.Single: writer.Write_float(o); break; case TypeCode.Double: writer.Write_double(o); break; case TypeCode.Decimal: writer.Write_decimal(o); break; case TypeCode.DateTime: writer.Write_dateTime(o); break; case TypeCode.Char: writer.Write_char(o); break; case TypeCode.Byte: writer.Write_unsignedByte(o); break; case TypeCode.SByte: writer.Write_byte(o); break; case TypeCode.UInt16: writer.Write_unsignedShort(o); break; case TypeCode.UInt32: writer.Write_unsignedInt(o); break; case TypeCode.UInt64: writer.Write_unsignedLong(o); break; default: if (primitiveType == typeof(XmlQualifiedName)) { writer.Write_QName(o); } else if (primitiveType == typeof(byte[])) { writer.Write_base64Binary(o); } else if (primitiveType == typeof(Guid)) { writer.Write_guid(o); } else { throw new InvalidOperationException(Res.GetString(Res.XmlUnxpectedType, primitiveType.FullName)); } break; } }
private void SerializePrimitive(XmlWriter xmlWriter, object o, XmlSerializerNamespaces namespaces) { XmlSerializationPrimitiveWriter writer = new XmlSerializationPrimitiveWriter(); writer.Init(xmlWriter, namespaces, null, null, null); switch (Type.GetTypeCode(this.primitiveType)) { case TypeCode.Boolean: writer.Write_boolean(o); return; case TypeCode.Char: writer.Write_char(o); return; case TypeCode.SByte: writer.Write_byte(o); return; case TypeCode.Byte: writer.Write_unsignedByte(o); return; case TypeCode.Int16: writer.Write_short(o); return; case TypeCode.UInt16: writer.Write_unsignedShort(o); return; case TypeCode.Int32: writer.Write_int(o); return; case TypeCode.UInt32: writer.Write_unsignedInt(o); return; case TypeCode.Int64: writer.Write_long(o); return; case TypeCode.UInt64: writer.Write_unsignedLong(o); return; case TypeCode.Single: writer.Write_float(o); return; case TypeCode.Double: writer.Write_double(o); return; case TypeCode.Decimal: writer.Write_decimal(o); return; case TypeCode.DateTime: writer.Write_dateTime(o); return; case TypeCode.String: writer.Write_string(o); return; } if (this.primitiveType == typeof(XmlQualifiedName)) { writer.Write_QName(o); } else if (this.primitiveType == typeof(byte[])) { writer.Write_base64Binary(o); } else { if (this.primitiveType != typeof(Guid)) { throw new InvalidOperationException(Res.GetString("XmlUnxpectedType", new object[] { this.primitiveType.FullName })); } writer.Write_guid(o); } }