Exemplo n.º 1
0
        public void OnObjectStart(string name)
        {
            var state = new KVPartialState();

            state.Key = name;
            StateStack.Push(state);
        }
 static void Merge(KVPartialState from, KVPartialState into)
 {
     foreach (var item in from.Items)
     {
         var matchingItem = into.Items.FirstOrDefault(i => i.Name == item.Name);
         if (matchingItem == null)
         {
             into.Items.Add(item);
         }
         else
         {
             Merge(from: item, into: matchingItem);
         }
     }
 }
Exemplo n.º 3
0
        public void OnKeyValuePair(string name, KVValue value)
        {
            if (StateStack.Count > 0)
            {
                var state = StateStack.Peek();
                state.Items.Add(new KVObject(name, value));
            }
            else
            {
                var state = new KVPartialState();
                state.Key   = name;
                state.Value = value;

                StateStack.Push(state);
            }
        }
Exemplo n.º 4
0
        KVObject MakeObject(KVPartialState state)
        {
            if (state.Discard)
            {
                return(null);
            }

            KVObject @object;

            if (state.Value != null)
            {
                @object = new KVObject(state.Key, state.Value);
            }
            else
            {
                @object = new KVObject(state.Key, state.Items);
            }

            return(@object);
        }