WriteJson() public method

Writes the JSON representation of the object.
public WriteJson ( JsonWriter writer, object value, JsonSerializer serializer ) : void
writer JsonWriter The to write to.
value object The value.
serializer JsonSerializer The calling serializer.
return void
示例#1
0
        /// <summary>
        /// Writes the JSON representation of the object.
        /// </summary>
        /// <param name="writer">The <see cref="JsonWriter"/> to write to.</param>
        /// <param name="value">The value.</param>
        /// <param name="serializer">The calling serializer.</param>
        public override void WriteJson(JsonWriter writer, object?value, JsonSerializer serializer)
        {
            if (value == null)
            {
                writer.WriteNull();
                return;
            }

            DataSet dataSet = (DataSet)value;
            DefaultContractResolver?resolver =
                serializer.ContractResolver as DefaultContractResolver;

            DataTableConverter converter = new DataTableConverter();

            writer.WriteStartObject();

            foreach (DataTable table in dataSet.Tables)
            {
                writer.WritePropertyName(
                    (resolver != null)
                      ? resolver.GetResolvedPropertyName(table.TableName)
                      : table.TableName
                    );

                converter.WriteJson(writer, table, serializer);
            }

            writer.WriteEndObject();
        }
示例#2
0
 public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
 {
   DataSet dataSet = (DataSet) value;
   DefaultContractResolver contractResolver = serializer.ContractResolver as DefaultContractResolver;
   DataTableConverter dataTableConverter = new DataTableConverter();
   writer.WriteStartObject();
   foreach (DataTable dataTable in (InternalDataCollectionBase) dataSet.Tables)
   {
     writer.WritePropertyName(contractResolver != null ? contractResolver.GetResolvedPropertyName(dataTable.TableName) : dataTable.TableName);
     dataTableConverter.WriteJson(writer, (object) dataTable, serializer);
   }
   writer.WriteEndObject();
 }
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            DefaultContractResolver contractResolver = serializer.ContractResolver as DefaultContractResolver;
            DataTableConverter      converter        = new DataTableConverter();

            writer.WriteStartObject();
            foreach (DataTable table in ((DataSet)value).Tables)
            {
                writer.WritePropertyName((contractResolver != null) ? contractResolver.GetResolvedPropertyName(table.TableName) : table.TableName);
                converter.WriteJson(writer, table, serializer);
            }
            writer.WriteEndObject();
        }
示例#4
0
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            DataSet dataSet = (DataSet)value;
            DefaultContractResolver contractResolver   = serializer.ContractResolver as DefaultContractResolver;
            DataTableConverter      dataTableConverter = new DataTableConverter();

            writer.WriteStartObject();
            foreach (DataTable dataTable in (InternalDataCollectionBase)dataSet.Tables)
            {
                writer.WritePropertyName(contractResolver != null ? contractResolver.GetResolvedPropertyName(dataTable.TableName) : dataTable.TableName);
                dataTableConverter.WriteJson(writer, (object)dataTable, serializer);
            }
            writer.WriteEndObject();
        }
示例#5
0
        /// <summary>
        /// Writes the JSON representation of the object.
        /// </summary>
        /// <param name="writer">The <see cref="JsonWriter"/> to write to.</param>
        /// <param name="value">The value.</param>
        /// <param name="serializer">The calling serializer.</param>
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            DataSet dataSet = (DataSet)value;

            DataTableConverter converter = new DataTableConverter();

            writer.WriteStartObject();

            foreach (DataTable table in dataSet.Tables)
            {
                writer.WritePropertyName(table.TableName);

                converter.WriteJson(writer, table, serializer);
            }

            writer.WriteEndObject();
        }
示例#6
0
    /// <summary>
    /// Writes the JSON representation of the object.
    /// </summary>
    /// <param name="writer">The <see cref="JsonWriter"/> to write to.</param>
    /// <param name="value">The value.</param>
    /// <param name="serializer">The calling serializer.</param>
    public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
    {
      DataSet dataSet = (DataSet)value;

      DataTableConverter converter = new DataTableConverter();

      writer.WriteStartObject();

      foreach (DataTable table in dataSet.Tables)
      {
        writer.WritePropertyName(table.TableName);
        
        converter.WriteJson(writer, table, serializer);
      }

      writer.WriteEndObject();
    }
    /// <summary>
    /// Writes the JSON representation of the object.
    /// </summary>
    /// <param name="writer">The <see cref="JsonWriter"/> to write to.</param>
    /// <param name="value">The value.</param>
    /// <param name="serializer">The calling serializer.</param>
    public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
    {
      DataSet dataSet = (DataSet)value;
      DefaultContractResolver resolver = serializer.ContractResolver as DefaultContractResolver;

      DataTableConverter converter = new DataTableConverter();

      writer.WriteStartObject();

      foreach (DataTable table in dataSet.Tables)
      {
        writer.WritePropertyName((resolver != null) ? resolver.ResolvePropertyName(table.TableName) : table.TableName);
        
        converter.WriteJson(writer, table, serializer);
      }

      writer.WriteEndObject();
    }
示例#8
0
        // Token: 0x06001492 RID: 5266 RVA: 0x0006CF34 File Offset: 0x0006B134
        public override void WriteJson(JsonWriter writer, [Nullable(2)] object value, JsonSerializer serializer)
        {
            if (value == null)
            {
                writer.WriteNull();
                return;
            }
            DataSet dataSet = (DataSet)value;
            DefaultContractResolver defaultContractResolver = serializer.ContractResolver as DefaultContractResolver;
            DataTableConverter      dataTableConverter      = new DataTableConverter();

            writer.WriteStartObject();
            foreach (object obj in dataSet.Tables)
            {
                DataTable dataTable = (DataTable)obj;
                writer.WritePropertyName((defaultContractResolver != null) ? defaultContractResolver.GetResolvedPropertyName(dataTable.TableName) : dataTable.TableName);
                dataTableConverter.WriteJson(writer, dataTable, serializer);
            }
            writer.WriteEndObject();
        }