private static void ExportControl(Control control, JsonWriter writer) { StringWriter innerWriter = new StringWriter(); HtmlTextWriter htmlWriter = GetHtmlWriter(innerWriter); control.RenderControl(htmlWriter); writer.WriteString(innerWriter.ToString()); }
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); } }
protected virtual void ExportTime(DateTime time, JsonWriter writer) { if (writer == null) { throw new ArgumentNullException("writer"); } writer.WriteString(FormatDateTime(time)); }
public void Playback(JsonWriter writer) { if (writer == null) { throw new ArgumentNullException("writer"); } writer.WriteFromReader(this.CreatePlayer()); }
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(); }
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(); }
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()); } } }
protected override void ExportValue(ExportContext context, object value, JsonWriter writer) { writer.WriteBoolean((bool) value); }
protected override void ExportValue(ExportContext context, object value, JsonWriter writer) { ExportControl((Control) value, writer); }
protected override void ExportValue(ExportContext context, object value, JsonWriter writer) { ExportDataSet(context, (DataSet) value, writer); }
protected override void ExportValue(ExportContext context, object value, JsonWriter writer) { writer.WriteNumber(((JsonNumber) value).ToString()); }
protected override void ExportValue(ExportContext context, object value, JsonWriter writer) { byte[] inArray = (byte[]) value; writer.WriteString(Convert.ToBase64String(inArray)); }
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 abstract void ExportValue(ExportContext context, object value, JsonWriter writer);
protected override void ExportValue(ExportContext context, object value, JsonWriter writer) { writer.WriteString(value.ToString()); }
protected override void ExportValue(ExportContext context, object value, JsonWriter writer) { ((IJsonExportable) value).Export(context, 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); }