示例#1
0
 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();
 }
 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();
 }
示例#4
0
 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);
             }
         }
     }
 }
示例#5
0
 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();
 }
示例#6
0
 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();
 }
 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();
 }