Example #1
0
 public virtual void Export(ExportContext context, object value, JsonWriter writer)
 {
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     if (writer == null)
     {
         throw new ArgumentNullException("writer");
     }
     if (JsonNull.LogicallyEquals(value))
     {
         writer.WriteNull();
     }
     else
     {
         this.ExportValue(context, value, writer);
     }
 }
 private static void ExportCollection(ExportContext context, NameValueCollection collection, JsonWriter writer)
 {
     writer.WriteStartObject();
     for (int i = 0; i < collection.Count; i++)
     {
         writer.WriteMember(collection.GetKey(i));
         string[] values = collection.GetValues(i);
         if (values == null)
         {
             writer.WriteNull();
         }
         else if (values.Length > 1)
         {
             context.Export(values, writer);
         }
         else
         {
             context.Export(values[0], writer);
         }
     }
     writer.WriteEndObject();
 }
Example #3
0
 public virtual void Export(object value, JsonWriter writer)
 {
     if (writer == null)
     {
         throw new ArgumentNullException("writer");
     }
     if (JsonNull.LogicallyEquals(value))
     {
         writer.WriteNull();
     }
     else
     {
         IExporter exporter = this.FindExporter(value.GetType());
         if (exporter != null)
         {
             exporter.Export(this, value, writer);
         }
         else
         {
             writer.WriteString(value.ToString());
         }
     }
 }