/// <summary>
        /// Adds an new items to specified DDAttributesCollection from its Json representation.
        /// </summary>
        /// <param name="ac">The deserialized attributes collection.</param>
        /// <param name="s">Json stream reader</param>
        internal static void JsonDeserialize(this DDAttributesCollection ac, JsonReader reader)
        {
            string prevValueString = null;
            string prevName        = null;

            JsonToken prevTokenType = JsonToken.None;

            while (reader.Read())
            {
                if (reader.TokenType == JsonToken.EndArray)
                {
                    break;                                         // end list of attributes
                }
                if ((reader.TokenType == JsonToken.PropertyName) && (prevTokenType == JsonToken.StartObject) && (reader.Value != null))
                {
                    ac.Add(reader.Value.ToString(), DDValueSje.Deserialize(reader));
                }
                //  save current values
                prevTokenType = reader.TokenType;
                if (reader.TokenType == JsonToken.None)
                {
                    prevValueString = null;
                    prevName        = null;
                }
                else if (reader.TokenType == JsonToken.PropertyName)
                {
                    prevName = reader.Value.ToString();
                }
                else if (reader.TokenType == JsonToken.String)
                {
                    prevValueString = reader.Value.ToString();
                }
            }
        }
        /// <summary>
        /// Serializes the specified DDAttributesCollection and writes the Json document to a Json writer
        /// </summary>
        /// <param name="ac">the attributes collection to serialize</param>
        /// <param name="writer">Json writer used to write the Json document.</param>
        internal static void JsonSerialize(DDAttributesCollection ac, JsonWriter writer)
        {
            writer.Formatting = Newtonsoft.Json.Formatting.Indented;
            if (ac.Count != 0)
            {
                writer.WritePropertyName(DDSchema.JSON_SERIALIZE_NODE_ATTRIBUTE_COLLECTION);
                writer.WriteStartArray();

                foreach (var a in ac)
                {
                    writer.WriteStartObject();
                    writer.WritePropertyName(a.Key);
                    writer.WriteStartObject();
                    if (a.Value != null)
                    {
                        DDValueSje.JsonSerialize(a.Value, writer);
                    }
                    writer.WriteEndObject();
                    writer.WriteEndObject();
                }
                writer.WriteEndArray();
            }
        }
Esempio n. 3
0
 /// <summary>
 ///  Generates an new DDValue from its Json representation.
 /// </summary>
 /// <param name="reader">Json stream reader</param>
 /// <returns>an new DDValue</returns>
 public void Deserialize(JsonReader reader)
 {
     this.v = DDValueSje.Deserialize(reader);
 }
Esempio n. 4
0
 /// <summary>
 /// Adds an new items to specified DDValue from its Json representation.
 /// </summary>
 /// <param name="s">Stream that contains the Json document to deserialize.</param>
 public void Deserialize(Stream s)
 {
     this.v = DDValueSje.Deserialize(s);
 }
Esempio n. 5
0
 /// <summary>
 /// Generates an new item to specified DDValue from its Json representation.
 /// </summary>
 /// <param name="tr">Text reader stream that contains the Json document to deserialize.</param>
 public void Deserialize(TextReader tr)
 {
     this.v = DDValueSje.Deserialize(tr);
 }
Esempio n. 6
0
 /// <summary>
 /// Generates an new item to specified DDValue from its Json representation.
 /// </summary>
 /// <param name="s">String that contains the Json document to deserialize.</param>
 public void Deserialize(string s)
 {
     this.v = DDValueSje.Deserialize(s);
 }