Beispiel #1
0
 /// <summary>
 /// Adds the specified key and value to the collection.
 /// </summary>
 /// <param name="key">The key of the element to add.</param>
 /// <param name="value">The value of the element to add.</param>
 public void Add(string key, UniValue value)
 {
     if (String.IsNullOrEmpty(key))
     {
         key = "____";
     }
     if (!this.ContainsKey(key))
     {
         // first key
         value.Key    = key;
         value.Parent = this.Parent;
         this.Items.Add(key, value);
         if (this.Parent != null && this.Parent.IsArraySubtype && !OAuthUtility.IsNumeric(key))
         {
             this.Parent.IsArraySubtype = false;
         }
     }
     else
     {
         // key exists
         if (this[key].IsArraySubtype)
         {
             // is array, push item
             this[key].Add(this[key].Count.ToString(), value);
         }
         else
         {
             // is not array, create it
             this[key]        = new UniValue(new UniValue[] { new UniValue(this[key]), value });
             this[key].Parent = this.Parent;
         }
         this[key].Key = key;
     }
 }