public void Write(object obj, FormatWriter writer) { DateTime value = (DateTime)obj; switch (context.DateTimeOptions.PackingFormat) { case DateTimePackingFormat.Extension: TimeSpan diff = value.ToUniversalTime() - epoch; writer.WriteExtHeader(12, ExtType); writer.WriteUInt32((uint)(value.Ticks % 10000000) * 100); writer.WriteUInt64((ulong)diff.TotalSeconds); break; case DateTimePackingFormat.String: writer.Write(value.ToString("o")); break; case DateTimePackingFormat.Epoch: writer.Write((value.ToUniversalTime() - epoch).TotalSeconds); break; default: throw new FormatException(); } }
public void Write(object obj, FormatWriter writer) { Vector2 vector = (Vector2)obj; writer.WriteArrayHeader(2); writer.Write(vector.x); writer.Write(vector.y); }
public void Write(object obj, FormatWriter writer) { if (obj == null) { writer.WriteNil(); return; } context.TypeHandlers.Get(obj.GetType()).Write(obj, writer); }
public void Write(object obj, FormatWriter writer) { if (obj == null) { writer.WriteNil(); return; } underlyingTypeHandler.Write(obj, writer); }
public void Write(object obj, FormatWriter writer) { Color color = (Color)obj; writer.WriteArrayHeader(4); writer.Write(color.r); writer.Write(color.g); writer.Write(color.b); writer.Write(color.a); }
public void Write(object obj, FormatWriter writer) { Vector4 vector = (Vector4)obj; writer.WriteArrayHeader(4); writer.Write(vector.x); writer.Write(vector.y); writer.Write(vector.z); writer.Write(vector.w); }
public void Write(object obj, FormatWriter writer) { Quaternion quaternion = (Quaternion)obj; writer.WriteArrayHeader(4); writer.Write(quaternion.x); writer.Write(quaternion.y); writer.Write(quaternion.z); writer.Write(quaternion.w); }
public void Write(object obj, FormatWriter writer) { Color32 color = (Color32)obj; writer.WriteBinHeader(4); writer.WriteRawByte(color.r); writer.WriteRawByte(color.g); writer.WriteRawByte(color.b); writer.WriteRawByte(color.a); }
public void Write(object obj, FormatWriter writer) { if (obj == null) { writer.WriteNil(); return; } string value = ((Uri)obj).ToString(); GetStringHandler().Write(value, writer); }
public void Write(object obj, FormatWriter writer) { if (obj == null) { writer.WriteNil(); return; } Array values = (Array)obj; writer.WriteArrayHeader(values.Length); foreach (object value in values) { elementTypeHandler.Write(value, writer); } }
public void Write(object obj, FormatWriter writer) { switch (context.EnumOptions.PackingFormat) { case EnumPackingFormat.Integer: intHandler = intHandler ?? context.TypeHandlers.Get <int>(); intHandler.Write(obj, writer); break; case EnumPackingFormat.String: stringHandler = stringHandler ?? context.TypeHandlers.Get <string>(); stringHandler.Write(obj.ToString(), writer); break; } }
public void Write(object obj, FormatWriter writer) { if (obj == null) { writer.WriteNil(); return; } IList values = (IList)obj; writer.WriteArrayHeader(values.Count); foreach (object value in values) { innerTypeHandler.Write(value, writer); } }
public void Write(object obj, FormatWriter writer) { if (obj == null) { writer.WriteNil(); return; } IDictionary dictionary = (IDictionary)obj; writer.WriteMapHeader(dictionary.Count); foreach (DictionaryEntry kv in dictionary) { keyHandler.Write(kv.Key, writer); valueHandler.Write(kv.Value, writer); } }
public void Write(object obj, FormatWriter writer) { if (obj == null) { writer.WriteNil(); return; } MapDefinition definition = lazyDefinition.Value; InvokeCallback <OnSerializingAttribute>(obj, definition); writer.WriteMapHeader(DetermineSize(obj, definition)); foreach (KeyValuePair <string, FieldInfo> kv in definition.FieldInfos) { object value = kv.Value.GetValue(obj); if (context.MapOptions.IgnoreNullOnPack && value == null) { continue; } string name = nameConverter.OnPack(kv.Key, definition); nameHandler.Write(name, writer); definition.FieldHandlers[kv.Key].Write(value, writer); } InvokeCallback <OnSerializedAttribute>(obj, definition); }
public void Write(object obj, FormatWriter writer) { writer.Write((string)obj); }
public void Write(object obj, FormatWriter writer) { writer.Write(Convert.ToUInt32(obj)); }
public void Write(object obj, FormatWriter writer) { writer.Write(((TimeSpan)obj).Ticks); }
public void Write(object obj, FormatWriter writer) { writer.Write((float)obj); }
public void Write(object obj, FormatWriter writer) { intArrayHandler = intArrayHandler ?? context.TypeHandlers.Get <int[]>(); int[] bits = decimal.GetBits((decimal)obj); intArrayHandler.Write(bits, writer); }
public void Write(object obj, FormatWriter writer) { binaryHandler = binaryHandler ?? context.TypeHandlers.Get <byte[]>(); binaryHandler.Write(((Guid)obj).ToByteArray(), writer); }
public void Write(object obj, FormatWriter writer) { writer.Write((bool)obj); }
public void Write(object obj, FormatWriter writer) { writer.Write((double)obj); }