Beispiel #1
0
        public void OnObjectStart(string name)
        {
            var state = new KvPartialState {
                Key = name
            };

            StateStack.Push(state);
        }
Beispiel #2
0
 private static KvObject MakeObject(KvPartialState state)
 {
     if (state.Discard)
     {
         return(null);
     }
     return(state.Value != null ? new KvObject(state.Key, state.Value) : new KvObject(state.Key, state.Items));
 }
Beispiel #3
0
 private 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(item, matchingItem);
         }
     }
 }
Beispiel #4
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 {
             Key = name, Value = value
         };
         StateStack.Push(state);
     }
 }