WriteJson() 공개 추상적인 메소드

Writes the JSON representation of the object.
public abstract WriteJson ( JsonWriter writer, object value, JsonSerializer serializer ) : void
writer JsonWriter The to write to.
value object The value.
serializer JsonSerializer The calling serializer.
리턴 void
 public override void WriteJson(Newtonsoft.Json.JsonWriter writer, object value, Newtonsoft.Json.JsonSerializer serializer)
 {
     if (value != null)
     {
         writeConverter.WriteJson(writer, baseDate.Add((TimeSpan)value), serializer);
     }
     else
     {
         writeConverter.WriteJson(writer, value, serializer);
     }
 }
예제 #2
0
        private void SerializeValue(JsonWriter writer, object value, JsonConverter memberConverter)
        {
            JsonConverter converter;

            if (value == null)
            {
                writer.WriteNull();
            }
            else if (memberConverter != null)
            {
                memberConverter.WriteJson(writer, value);
            }
            else if (HasClassConverter(value.GetType(), out converter))
            {
                converter.WriteJson(writer, value);
            }
            else if (HasMatchingConverter(value.GetType(), out converter))
            {
                converter.WriteJson(writer, value);
            }
            else if (JsonConvert.IsJsonPrimitive(value))
            {
                writer.WriteValue(value);
            }
            else if (value is IList)
            {
                SerializeList(writer, (IList)value);
            }
            else if (value is IDictionary)
            {
                SerializeDictionary(writer, (IDictionary)value);
            }
            else if (value is ICollection)
            {
                SerializeCollection(writer, (ICollection)value);
            }
            else if (value is IEnumerable)
            {
                SerializeEnumerable(writer, (IEnumerable)value);
            }
            else if (value is JsonRaw)
            {
                writer.WriteRawValue(((JsonRaw)value).Content);
            }
            else
            {
                SerializeObject(writer, value);
            }
        }
예제 #3
0
        private void SerializeValue(JsonWriter writer, object value, JsonConverter memberConverter)
        {
            JsonConverter converter;

              if (value == null)
              {
            writer.WriteNull();
              }
              else if (memberConverter != null)
              {
            memberConverter.WriteJson(writer, value);
              }
              else if (HasClassConverter(value.GetType(), out converter))
              {
            converter.WriteJson(writer, value);
              }
              else if (HasMatchingConverter(value.GetType(), out converter))
              {
            converter.WriteJson(writer, value);
              }
              else if (JsonConvert.IsJsonPrimitive(value))
              {
            writer.WriteValue(value);
              }
              else if (value is IList)
              {
            SerializeList(writer, (IList)value);
              }
              else if (value is IDictionary)
              {
            SerializeDictionary(writer, (IDictionary)value);
              }
              else if (value is ICollection)
              {
            SerializeCollection(writer, (ICollection)value);
              }
              else if (value is IEnumerable)
              {
            SerializeEnumerable(writer, (IEnumerable)value);
              }
              else if (value is JsonRaw)
              {
            writer.WriteRawValue(((JsonRaw)value).Content);
              }
              else
              {
            SerializeObject(writer, value);
              }
        }
예제 #4
0
 private void SerializeConvertable(JsonWriter writer, JsonConverter converter, object value, JsonContract contract, JsonContainerContract collectionContract, JsonProperty containerProperty)
 {
   if (this.ShouldWriteReference(value, (JsonProperty) null, contract, collectionContract, containerProperty))
   {
     this.WriteReference(writer, value);
   }
   else
   {
     if (!this.CheckForCircularReference(writer, value, (JsonProperty) null, contract, collectionContract, containerProperty))
       return;
     this._serializeStack.Add(value);
     converter.WriteJson(writer, value, (JsonSerializer) this.GetInternalSerializer());
     this._serializeStack.RemoveAt(this._serializeStack.Count - 1);
   }
 }