Esempio n. 1
0
 /// <summary>
 /// Serializes the specified DDValue and writes the Json document to a Json writer
 /// </summary>
 /// <param name="v">the value to serialize</param>
 /// <param name="writer">Json writer used to write the Json document.</param>
 internal static void JsonSerialize(DDValue v, JsonWriter writer)
 {
     writer.Formatting = Newtonsoft.Json.Formatting.Indented;
     writer.WritePropertyName(DDSchema.JSON_SERIALIZE_ATTRIBUTE_TYPE);
     if (v.Type == null)
     {
         writer.WriteNull();
     }
     else
     {
         writer.WriteValue(v.Type.ToString());
         writer.WritePropertyName(DDSchema.JSON_SERIALIZE_NODE_VALUE);
         var a = IsThisTypeJsonSerializeAsArray(v.Type);
         if (a)
         {
             writer.WriteStartArray();
             foreach (var i in (Array)v.GetValue())
             {
                 writer.WriteValue(i);
             }
             writer.WriteEndArray();
         }
         else
         {
             if (v.Type == typeof(byte[]))
             {
                 writer.WriteValue(v.GetValueAsHEX());
             }
             else
             {
                 writer.WriteValue(v.GetValue());
             }
         }
     }
 }