Esempio n. 1
0
 public void OnArray(int size)
 {
     if (size == 0)
     {
         CborArray array = new CborArray(0);
         array.Tag = currentTag;
         currentTag = null;
         OnObject(array);
     }
     else
     {
         stack.Push(DynamicParseState.ParseArray(size, currentTag));
         currentTag = null;
     }
 }
Esempio n. 2
0
        public void OnObject(CborObject obj)
        {
            if (currentTag != null)
            {
                obj.Tag = currentTag;
                currentTag = null;
            }

            if (stack.Any())
            {
                DynamicParseState state = stack.Peek();
                if (state.type == ParseType.MAP)
                {
                    if (state.currentKey == null)
                    {
                        state.currentKey = obj;
                    }
                    else
                    {
                        state.currentMap.Add(state.currentKey, obj);
                        state.currentKey = null;
                        state.currentIndex++;

                        if (state.currentIndex == state.maximumIndex)
                        {
                            stack.Pop();
                            OnObject(new CborMap(state.currentMap) {Tag = state.currentTag});
                        }
                    }
                }
                else // array
                {
                    state.currentArray[state.currentIndex] = obj;

                    state.currentIndex++;

                    if (state.currentIndex == state.maximumIndex)
                    {
                        stack.Pop();
                        CborArray array = new CborArray(state.currentArray);
                        array.Tag = state.currentTag;
                        OnObject(array);
                    }
                }
            }
            else
            {
                OnRootObject(obj);
            }
        }
Esempio n. 3
0
 protected bool Equals(CborArray other)
 {
     return Value.Equals(other.Value);
 }