本文整理汇总了C#中JsonWriter.WriteMember方法的典型用法代码示例。如果您正苦于以下问题:C# JsonWriter.WriteMember方法的具体用法?C# JsonWriter.WriteMember怎么用?C# JsonWriter.WriteMember使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonWriter
的用法示例。
在下文中一共展示了JsonWriter.WriteMember方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExportDataSet
private static void ExportDataSet(ExportContext context, DataSet dataSet, JsonWriter writer)
{
Debug.Assert(context != null);
Debug.Assert(dataSet != null);
Debug.Assert(writer != null);
writer.WriteStartObject();
foreach (DataTable table in dataSet.Tables)
{
writer.WriteMember(table.TableName);
//
// If there is an exporter (perhaps an override) for the
// DataTable in effect then use it. Otherwise our
// DataTableExporter.
//
IExporter tableExporter = context.FindExporter(table.GetType());
if (tableExporter != null)
tableExporter.Export(context, table, writer);
else
DataTableExporter.ExportTable(context, table, writer);
}
writer.WriteEndObject();
}
示例2: ExportValue
protected override void ExportValue(ExportContext context, object value, JsonWriter writer)
{
Debug.Assert(context != null);
Debug.Assert(value != null);
Debug.Assert(writer != null);
if (_properties.Count == 0)
{
writer.WriteString(value.ToString());
}
else
{
writer.WriteStartObject();
foreach (PropertyDescriptor property in _properties)
{
object propertyValue = property.GetValue(value);
if (!JsonNull.LogicallyEquals(propertyValue))
{
writer.WriteMember(property.Name);
context.Export(propertyValue, writer);
}
}
writer.WriteEndObject();
}
}
示例3: FormatOther
protected override void FormatOther(object o, JsonWriter writer)
{
if (writer == null)
throw new ArgumentNullException("writer");
if (JNull.LogicallyEquals(o))
{
FormatNull(o, writer);
return;
}
writer.WriteStartObject();
if (_properties == null)
_properties = TypeDescriptor.GetProperties(o);
foreach (PropertyDescriptor property in _properties)
{
// TODO: Allow someone to indicate via an attribute (e.g. JsonIgnore) that a property should be excluded.
object value = property.GetValue(o);
if (!JNull.LogicallyEquals(value))
{
writer.WriteMember(property.Name);
writer.WriteValue(value);
}
}
writer.WriteEndObject();
}
示例4: Write
static void Write(JsonWriter json)
{
json.WriteObjectStart();
json.WriteAttribute("age", 30);
json.WriteAttribute("first", "John");
json.WriteAttribute("last", "Smith");
json.WriteMember("phoneNumbers");
json.WriteArrayStart();
json.WriteString("425-000-1212");
json.WriteString("425-000-1213");
json.WriteArrayEnd();
json.WriteMember("address");
json.WriteObjectStart();
json.WriteAttribute("street", "1 Microsoft Way");
json.WriteAttribute("city", "Redmond");
json.WriteAttribute("zip", 98052);
json.WriteObjectEnd();
json.WriteObjectEnd();
}
示例5: FormatTable
internal static void FormatTable(DataTable table, JsonWriter writer)
{
Debug.Assert(table != null);
Debug.Assert(writer != null);
writer.WriteStartObject();
writer.WriteMember("rows");
writer.WriteValue(table.Rows);
writer.WriteEndObject();
}
示例6: FormatRowView
private static void FormatRowView(DataRowView rowView, JsonWriter writer)
{
writer.WriteStartObject();
foreach (DataColumn column in rowView.DataView.Table.Columns)
{
writer.WriteMember(column.ColumnName);
writer.WriteValue(rowView[column.Ordinal]);
}
writer.WriteEndObject();
}
示例7: ExportMembers
private static void ExportMembers(ExportContext context, IEnumerable<KeyValuePair<string, object>> members, JsonWriter writer)
{
Debug.Assert(context != null);
Debug.Assert(members != null);
Debug.Assert(writer != null);
foreach (var member in members)
{
writer.WriteMember(member.Key);
context.Export(member.Value, writer);
}
}
示例8: FormatDataSet
private static void FormatDataSet(DataSet dataSet, JsonWriter writer)
{
writer.WriteStartObject();
foreach (DataTable table in dataSet.Tables)
{
writer.WriteMember(table.TableName);
DataTableFormatter.FormatTable(table, writer);
}
writer.WriteEndObject();
}
示例9: ExportValue
protected override void ExportValue(ExportContext context, object value, JsonWriter writer)
{
Debug.Assert(context != null);
Debug.Assert(value != null);
Debug.Assert(writer != null);
if (_properties.Count == 0)
{
writer.WriteString(value.ToString());
}
else
{
ObjectReferenceTracker tracker = null;
try
{
writer.WriteStartObject();
foreach (PropertyDescriptor property in _properties)
{
object propertyValue = property.GetValue(value);
if (!JsonNull.LogicallyEquals(propertyValue))
{
writer.WriteMember(property.Name);
if (tracker == null)
{
//
// We are about to enter a deeper scope so
// start tracking the current object being
// exported. This will help to detect
// recursive references that may occur
// through this exporter deeper in the tree.
//
tracker = TrackObject(context, value);
}
context.Export(propertyValue, writer);
}
}
writer.WriteEndObject();
}
finally
{
if (tracker != null)
tracker.Pop(value);
}
}
}
示例10: ExportValue
protected override void ExportValue(object value, JsonWriter writer)
{
writer.WriteStartObject();
IDictionary dictionary = (IDictionary) value;
foreach (DictionaryEntry entry in dictionary)
{
writer.WriteMember(entry.Key.ToString());
writer.WriteValue(entry.Value);
}
writer.WriteEndObject();
}
示例11: FormatView
internal static void FormatView(DataView view, JsonWriter writer)
{
Debug.Assert(view != null);
Debug.Assert(writer != null);
writer.WriteStartObject();
writer.WriteMember("columns");
writer.WriteStartArray();
foreach (DataColumn column in view.Table.Columns)
writer.WriteValue(column.ColumnName);
writer.WriteEndArray();
writer.WriteMember("rows");
writer.WriteStartArray();
foreach (DataRowView row in view)
writer.WriteValue(row.Row.ItemArray);
writer.WriteEndArray();
writer.WriteEndObject();
}
示例12: ExportDataSet
private static void ExportDataSet(DataSet dataSet, JsonWriter writer)
{
Debug.Assert(dataSet != null);
Debug.Assert(writer != null);
writer.WriteStartObject();
foreach (DataTable table in dataSet.Tables)
{
writer.WriteMember(table.TableName);
DataTableExporter.ExportTable(table, writer);
}
writer.WriteEndObject();
}
示例13: ExportView
internal static void ExportView(ExportContext context, DataView view, JsonWriter writer)
{
Debug.Assert(context != null);
Debug.Assert(view != null);
Debug.Assert(writer != null);
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 row in view)
context.Export(row.Row.ItemArray, writer);
writer.WriteEndArray();
writer.WriteEndObject();
}
示例14: FormatDataRow
internal static void FormatDataRow(DataRow row, JsonWriter writer)
{
Debug.Assert(row != null);
Debug.Assert(writer != null);
writer.WriteStartObject();
foreach (DataColumn column in row.Table.Columns)
{
writer.WriteMember(column.ColumnName);
writer.WriteValue(row[column]);
}
writer.WriteEndObject();
}
示例15: ExportRow
internal static void ExportRow(ExportContext context, DataRow row, JsonWriter writer)
{
Debug.Assert(context != null);
Debug.Assert(row != null);
Debug.Assert(writer != null);
writer.WriteStartObject();
foreach (DataColumn column in row.Table.Columns)
{
writer.WriteMember(column.ColumnName);
context.Export(row[column], writer);
}
writer.WriteEndObject();
}