Example #1
0
        public void Insert(int index, Field item)
        {
            switch (fieldType)
            {
            case FieldType.Array:
                ListValue.Insert(index, item);
                break;

            case FieldType.Object:
                HashValue.Add(index.ToString(), item);
                break;

            default:
                throw new NotSupportedException();
            }
        }
Example #2
0
        public void Add(string key, Field value)
        {
            switch (fieldType)
            {
            case FieldType.Array:
                if (int.TryParse(key, out int index) && EnsuereRange(ref index))
                {
                    ListValue[index] = value;
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                break;

            case FieldType.Object:
                HashValue.Add(key, value);
                break;

            default:
                throw new NotSupportedException();
            }
        }