Example #1
0
        public void Add(dynamic value)
        {
            IsArray.AssertTrue();
            var max_index = _complex.Keys.Select(s => int.Parse(s)).MaxOrDefault(-1);

            // todo. wtf dynamic ain't work here as well
            _complex.Add(ImportKey(max_index + 1), ImportValue((Object)value));
        }
Example #2
0
        public void Insert(int index, dynamic value)
        {
            IsArray.AssertTrue();

            var before = _complex.Where(kvp => int.Parse(kvp.Key) < index).ToDictionary();
            // todo. wtf dynamic ain't work here as well
            var inserted = new KeyValuePair <String, Json>(ImportKey(index), ImportValue((Object)value)).MkArray().ToDictionary();
            var after    = _complex.Where(kvp => int.Parse(kvp.Key) >= index).ToDictionary(kvp => (int.Parse(kvp.Key) + 1).ToString(), kvp => kvp.Value);

            _complex.Clear();
            _complex.AddElements(before);
            _complex.AddElements(inserted);
            _complex.AddElements(after);
        }
Example #3
0
 public void RemoveAt(int index)
 {
     IsArray.AssertTrue();
     _complex.Remove(ImportKey(index));
 }
Example #4
0
 public int IndexOf(dynamic value)
 {
     IsArray.AssertTrue();
     // todo. wtf dynamic ain't work here as well
     return(_complex.IndexOf(kvp => Equals(kvp.Value, ImportValue((Object)value))));
 }
Example #5
0
 public bool Contains(dynamic value)
 {
     IsArray.AssertTrue();
     return(IndexOf(ImportValue(value)) != -1);
 }