public void Write(object obj, FormatWriter writer)
 {
     if (obj == null)
     {
         writer.WriteNil();
         return;
     }
     underlyingTypeHandler.Write(obj, writer);
 }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        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;
            }
        }
Exemplo n.º 5
0
        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);
            }
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
 public void Write(object obj, FormatWriter writer)
 {
     intArrayHandler = intArrayHandler ?? context.TypeHandlers.Get <int[]>();
     int[] bits = decimal.GetBits((decimal)obj);
     intArrayHandler.Write(bits, writer);
 }
Exemplo n.º 8
0
 public void Write(object obj, FormatWriter writer)
 {
     binaryHandler = binaryHandler ?? context.TypeHandlers.Get <byte[]>();
     binaryHandler.Write(((Guid)obj).ToByteArray(), writer);
 }