Exemplo n.º 1
0
 /// <summary>
 /// Add an object at the end of the collection
 /// </summary>
 /// <param name="item"></param>
 public void Add(JToken item)
 {
     this.Insert(
         this._items.Count,
         item
         );
 }
Exemplo n.º 2
0
 /// <summary>
 /// Insert an object at the specified position
 /// </summary>
 /// <param name="position"></param>
 /// <param name="item"></param>
 public void Insert(
     int position,
     JToken item
     )
 {
     this._items.Insert(
         position,
         item
         );
 }
Exemplo n.º 3
0
 public JProperty(
     string name,
     JToken value
     )
 {
     this.Name = name;
     this.Value = value;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Serialize the specific DOM to a JSON-string
 /// </summary>
 /// <param name="source"></param>
 /// <returns></returns>
 public static string Serialize(JToken source)
 {
     var sb = new StringBuilder();
     source.Serialize(sb);
     return sb.ToString();
 }
Exemplo n.º 5
0
        /// <summary>
        /// Add a keyed-value to the object's bag
        /// </summary>
        /// <param name="name"></param>
        /// <param name="value"></param>
        /// <remarks>You cannot use a key that is already existent in the bag</remarks>
        public void Add(string name, JToken value)
        {
            if (this.IndexOf(name) > 0)
                throw new ArgumentException("Duplicate key.");

            if (this._itemCount >= this._items.Length)
            {
                var old = this._items;
                Array.Copy(
                    old,
                    this._items = new JProperty[this._itemCount + ChunkSize],
                    this._itemCount
                    );
            }

            this._items[this._itemCount++] = new JProperty(name, value);
        }