public static void WriteValue(WriterState writer, decimal val) { // Decimals are stored as IEEE 754-2008 Decimal128 format https://en.wikipedia.org/wiki/Decimal128_floating-point_format // The IEEE version has higher precision than .net's decimal implementation and is compatible with other platforms var d = new Decimal128(val); writer.Write(d.GetIeeeHighBits()); writer.Write(d.GetIeeeLowBits()); }
public void Write(WriterState writer, IEnumerable list) { foreach (var item in (IEnumerable <T>)list) { writer.Write((byte)EnumerableType.HasItem); Serializer.WriteNonPrimitive(writer, item); } writer.Write((byte)EnumerableType.End); }
public static void Write(WriterState writer, sbyte val) { writer.Write((byte)SerializedType.SByte); writer.Write(val); }
public static void Write(WriterState writer, bool val) { writer.Write((byte)SerializedType.Bool); writer.Write(val); }
public static void Write(WriterState writer, float val) { writer.Write((byte)SerializedType.Float); writer.Write(val); }
public static void Write(WriterState writer, double val) { writer.Write((byte)SerializedType.Double); writer.Write(val); }
public static void WriteValue(WriterState writer, ulong val) { writer.Write(val); }
public static void Write(WriterState writer, uint val) { writer.Write((byte)SerializedType.UInt); writer.Write(val); }
public static unsafe void Write(WriterState writer, Guid val) { writer.Write((byte)SerializedType.Guid); val.TryWriteBytes(writer.Reserve(sizeof(Guid))); }
public static void WriteValue(WriterState writer, char val) { writer.Write(val); }
public static void WriteValue(WriterState writer, sbyte val) { writer.Write(val); }
public static void Write(WriterState writer, long val) { writer.Write((byte)SerializedType.Long); writer.Write(val); }
public static void WriteValue(WriterState writer, float val) { writer.Write(val); }
public static void Write(WriterState writer, string val) { writer.Write((byte)SerializedType.String); writer.WriteString(val); }
public static void Write(WriterState writer, char val) { writer.Write((byte)SerializedType.Char); writer.Write(val); }
public static void Write(WriterState writer, DateTime val) { writer.Write((byte)SerializedType.DateTime); writer.Write(val.ToUniversalTime().Ticks); }
public static void WriteValue(WriterState writer, DateTime val) { writer.Write(val.ToUniversalTime().Ticks); }
public static void Write(WriterState writer, ushort val) { writer.Write((byte)SerializedType.UShort); writer.Write(val); }
public static void WriteValue(WriterState writer, ushort val) { writer.Write(val); }