Ejemplo n.º 1
0
        public void RemoveAt(int index)
        {
            var newLength = ArrayLength - 1;

            for (var i = index + 1; i <= newLength; i++)
            {
                Children[VariantMap.GetIndexString(i - 1)] = Children[VariantMap.GetIndexString(i)];
            }
            Children.Remove(VariantMap.GetIndexString(newLength));
            ArrayLength = newLength;
        }
Ejemplo n.º 2
0
        public void Insert <T>(int index, T value)
        {
            var oldlength = ArrayLength;

            for (var i = oldlength; i > index; i--)
            {
                Children[VariantMap.GetIndexString(i)] = Children[VariantMap.GetIndexString(i - 1)];
            }
            Children[VariantMap.GetIndexString(index)] = value is Variant ? value as Variant : Get(value);
            ArrayLength++;
        }
Ejemplo n.º 3
0
        public static Variant GetList(params Variant[] items)
        {
            var map = GlobalPool <VariantMap> .GetObject();

            map.IsArray = true;
            for (var i = 0; i < items.Length; i++)
            {
                map[VariantMap.GetIndexString(i)] = items[i];
            }
            map.ArrayLength = items.Length;
            return(Get(map));
        }
Ejemplo n.º 4
0
        public void SetValue(IList <Variant> array)
        {
            var vm = new VariantMap();

            Value          = vm;
            ValueType      = VariantType.Map;
            vm.IsArray     = true;
            vm.ArrayLength = array.Count;
            for (var i = 0; i < vm.ArrayLength; i++)
            {
                vm[VariantMap.GetIndexString(i)] = array[i];
            }
        }
Ejemplo n.º 5
0
 public Variant this[int index]
 {
     get
     {
         Variant result = null;
         (Value as VariantMap)?.TryGetValue(VariantMap.GetIndexString(index), out result);
         return(result);
     }
     set
     {
         var v = Value as VariantMap;
         if (v == null)
         {
             SetValue(v = GlobalPool <VariantMap> .GetObject());
         }
         if (index > v.ArrayLength - 1)
         {
             v.ArrayLength = index + 1;
         }
         v[VariantMap.GetIndexString(index)] = value;
         IsArray = true;
     }
 }