protected override void ExportValue(ExportContext context, object value, JsonWriter writer)
 {
     string str;
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     if (writer == null)
     {
         throw new ArgumentNullException("writer");
     }
     try
     {
         str = this.ConvertToString(value);
     }
     catch (InvalidCastException exception)
     {
         throw new JsonException(exception.Message, exception);
     }
     writer.WriteNumber(str);
 }
 private static void ExportMembers(ExportContext context, IEnumerable<KeyValuePair<string, object>> members, JsonWriter writer)
 {
     foreach (KeyValuePair<string, object> pair in members)
     {
         writer.WriteMember(pair.Key);
         context.Export(pair.Value, writer);
     }
 }
 internal static void ExportRow(ExportContext context, DataRow row, JsonWriter writer)
 {
     writer.WriteStartObject();
     foreach (DataColumn column in row.Table.Columns)
     {
         writer.WriteMember(column.ColumnName);
         context.Export(row[column], writer);
     }
     writer.WriteEndObject();
 }
 protected override void ExportValue(ExportContext context, object value, JsonWriter writer)
 {
     writer.WriteStartObject();
     IDictionary dictionary = (IDictionary) value;
     foreach (DictionaryEntry entry in DictionaryHelper.GetEntries(dictionary))
     {
         writer.WriteMember(entry.Key.ToString());
         context.Export(entry.Value, writer);
     }
     writer.WriteEndObject();
 }
 internal static void ExportTable(ExportContext context, DataTable table, JsonWriter writer)
 {
     DataView defaultView = table.DefaultView;
     IExporter exporter = context.FindExporter(defaultView.GetType());
     if (exporter != null)
     {
         exporter.Export(context, defaultView, writer);
     }
     else
     {
         DataViewExporter.ExportView(context, defaultView, writer);
     }
 }
 protected override void ExportValue(ExportContext context, object value, JsonWriter writer)
 {
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     if (writer == null)
     {
         throw new ArgumentNullException("writer");
     }
     writer.WriteStartObject();
     ExportMembers(context, (ExpandoObject) value, writer);
     writer.WriteEndObject();
 }
 protected override void ExportValue(ExportContext context, object value, JsonWriter writer)
 {
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     if (writer == null)
     {
         throw new ArgumentNullException("writer");
     }
     this.ExportTime((DateTime) value, writer);
 }
 protected override void ExportValue(ExportContext context, object value, JsonWriter writer)
 {
     if (this._properties.Count == 0)
     {
         writer.WriteString(value.ToString());
     }
     else
     {
         ObjectReferenceTracker tracker = null;
         try
         {
             writer.WriteStartObject();
             int num = 0;
             foreach (PropertyDescriptor descriptor in this._properties)
             {
                 IObjectMemberExporter exporter = ((this._exporters != null) && (num < this._exporters.Length)) ? this._exporters[num++] : null;
                 if (exporter != null)
                 {
                     exporter.Export(context, writer, value);
                 }
                 else
                 {
                     object o = descriptor.GetValue(value);
                     if (!JsonNull.LogicallyEquals(o))
                     {
                         writer.WriteMember(descriptor.Name);
                         if (value.GetType().IsClass && (tracker == null))
                         {
                             tracker = TrackObject(context, value);
                         }
                         context.Export(o, writer);
                     }
                 }
             }
             writer.WriteEndObject();
         }
         finally
         {
             if (tracker != null)
             {
                 tracker.Pop(value);
             }
         }
     }
 }
 private static void ExportDataSet(ExportContext context, DataSet dataSet, JsonWriter writer)
 {
     writer.WriteStartObject();
     foreach (DataTable table in dataSet.Tables)
     {
         writer.WriteMember(table.TableName);
         IExporter exporter = context.FindExporter(table.GetType());
         if (exporter != null)
         {
             exporter.Export(context, table, writer);
         }
         else
         {
             DataTableExporter.ExportTable(context, table, writer);
         }
     }
     writer.WriteEndObject();
 }
 internal static void ExportView(ExportContext context, DataView view, JsonWriter writer)
 {
     writer.WriteStartObject();
     writer.WriteMember("columns");
     writer.WriteStartArray();
     foreach (DataColumn column in view.Table.Columns)
     {
         context.Export(column.ColumnName, writer);
     }
     writer.WriteEndArray();
     writer.WriteMember("rows");
     writer.WriteStartArray();
     foreach (DataRowView view2 in view)
     {
         context.Export(view2.Row.ItemArray, writer);
     }
     writer.WriteEndArray();
     writer.WriteEndObject();
 }
Beispiel #11
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();
 }
Beispiel #13
0
 protected override void ExportValue(ExportContext context, object value, JsonWriter writer)
 {
     writer.WriteBoolean((bool) value);
 }
Beispiel #14
0
 protected override void ExportValue(ExportContext context, object value, JsonWriter writer)
 {
     ExportDataSet(context, (DataSet) value, writer);
 }
Beispiel #15
0
 protected override void ExportValue(ExportContext context, object value, JsonWriter writer)
 {
     ExportControl((Control) value, writer);
 }
 protected override void ExportValue(ExportContext context, object value, JsonWriter writer)
 {
     writer.WriteNumber(((JsonNumber) value).ToString());
 }
 private static ObjectReferenceTracker TrackObject(ExportContext context, object value)
 {
     Type key = typeof(ComponentExporter);
     ObjectReferenceTracker tracker = (ObjectReferenceTracker) context.Items[key];
     if (tracker == null)
     {
         tracker = new ObjectReferenceTracker();
         context.Items.Add(key, tracker);
     }
     tracker.PushNew(value);
     return tracker;
 }
 protected override void ExportValue(ExportContext context, object value, JsonWriter writer)
 {
     byte[] inArray = (byte[]) value;
     writer.WriteString(Convert.ToBase64String(inArray));
 }
Beispiel #19
0
 protected override void ExportValue(ExportContext context, object value, JsonWriter writer)
 {
     writer.WriteString(value.ToString());
 }
 public void Export(ExportContext context, JsonWriter writer, object source)
 {
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     if (writer == null)
     {
         throw new ArgumentNullException("writer");
     }
     if (source == null)
     {
         throw new ArgumentNullException("source");
     }
     object o = this._property.GetValue(source);
     if (!JsonNull.LogicallyEquals(o) && !o.Equals(this._defaultValue))
     {
         writer.WriteMember(this._property.Name);
         context.Export(o, writer);
     }
 }
 protected override void ExportValue(ExportContext context, object value, JsonWriter writer)
 {
     ((IJsonExportable) value).Export(context, writer);
 }
Beispiel #22
0
 protected abstract void ExportValue(ExportContext context, object value, JsonWriter writer);
 protected override void ExportValue(ExportContext context, object value, JsonWriter writer)
 {
     writer.WriteFromReader(((JsonBuffer) value).CreateReader());
 }
 protected override void ExportValue(ExportContext context, object value, JsonWriter writer)
 {
     ExportCollection(context, (NameValueCollection) value, writer);
 }