public void Write(IJsonWriter writer, ITypeWriterRegistry registry, object value)
 {
     if (value == null)
     {
         writer.WriteNull();
     }
     else if (value.GetType() != typeof (object))
     {
         registry.Write(writer, value);
     }
     else
     {
         writer.WriteObjectStart();
         writer.WriteObjectEnd(0);
     }
 }
示例#2
0
        public void Write(IJsonWriter writer, ITypeWriterRegistry registry, object value)
        {
            var enumerable = value as IEnumerable;
            if (enumerable == null)
            {
                writer.WriteNull();
            }
            else
            {
                writer.WriteArrayStart();

                var index = 0;
                foreach (var item in enumerable)
                {
                    if (index++ > 0)
                    {
                        writer.WriteArrayElementDelimiter();
                    }
                    registry.Write(writer, item);
                }
                writer.WriteArrayEnd(index);
            }
        }