public void Write(object obj, FormatWriter writer) { if (obj == null) { writer.WriteNil(); return; } underlyingTypeHandler.Write(obj, 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) { 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) { 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; } 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) { 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); }