Пример #1
0
        private JItem InitializeStructure()
        {
            JKeyValuePair newPair = new JKeyValuePair("", "");
            JRoot         Root    = new JRoot();

            _keyValueStack.Clear();
            _itemStack.Clear();
            _syntaxChars.Clear();

            _keyValueStack.Push(newPair);
            _itemStack.Push(Root);
            _syntaxChars.Push(',');

            _indexOfTheChar = -1;
            _currentItem    = Root;
            return(_itemStack.First());
        }
Пример #2
0
 private void HandleColon()
 {
     _currentKeyValuePair = _keyValueStack.Peek();
     _currentItem         = _itemStack.Peek();
     _syntaxChars.Push(':');
     if (!_pendingForPairValue)
     {
         JKeyValuePair pair =
             new JKeyValuePair(JItemFactory.JSingleValue(_JItemContentsBuffer.ToString()), null);
         (_currentItem as JCollection).Add(pair);
         _keyValueStack.Push(pair);
     }
     else
     {
         //throw new InvalidEnumArgumentException();
     }
     _pendingForPairValue = true;
     _JItemContentsBuffer.Clear();
 }
Пример #3
0
 private void HandleCurlyBracket()
 {
     _currentKeyValuePair = _keyValueStack.Peek();
     _currentItem         = _itemStack.Peek();
     if (_pendingForPairValue)
     {
         JObject item = new JObject(_currentItem);
         _currentKeyValuePair.Value = item;
         _JItemContentsBuffer.Clear();
         CacheKeyValueAndCurrentItem(item);
         _pendingForPairValue = false;
     }
     else
     {
         JObject nItm = new JObject(_currentItem);
         (_currentItem as JCollection).Add(nItm);
         nItm.Parent = _currentItem;
         _itemStack.Push(nItm);
     }
 }
Пример #4
0
 private void HandleClosingCurlyBracket()
 {
     _currentKeyValuePair = _keyValueStack.Peek();
     _currentItem         = _itemStack.Peek();
     if (_pendingForPairValue)
     {
         JItem item = JItemFactory.JSingleValue(_JItemContentsBuffer.ToString(), _currentItem);
         _currentKeyValuePair.Value = item;
         _JItemContentsBuffer.Clear();
         _keyValueStack.Pop();
         _pendingForPairValue = false;
     }
     else
     {
         if (!string.IsNullOrWhiteSpace(_JItemContentsBuffer.ToString()))
         {
             _currentItem.Add(JItemFactory.JSingleValue(_JItemContentsBuffer.ToString(), _currentItem));
             _JItemContentsBuffer.Clear();
         }
     }
     _itemStack.Pop();
 }
Пример #5
0
 private void HandleComma()
 {
     _currentKeyValuePair = _keyValueStack.Peek();
     _currentItem         = _itemStack.Peek();
     if (_pendingForPairValue)
     {
         JItem jI = JItemFactory.JSingleValue(_JItemContentsBuffer.ToString(), _currentItem);
         _currentKeyValuePair.Value = jI;
         _keyValueStack.Pop();
         _pendingForPairValue = false;
     }
     else
     {
         if (!string.IsNullOrWhiteSpace(_JItemContentsBuffer.ToString()))
         {
             (_currentItem as JCollection).Add(JItemFactory.JSingleValue(_JItemContentsBuffer.ToString(), _currentItem));
             _JItemContentsBuffer.Clear();
             return;
         }
     }
     _syntaxChars.Push(',');
     _JItemContentsBuffer.Clear();
 }
Пример #6
0
 /// <summary>
 /// Recursively finds the pair idented by key.
 /// </summary>
 /// <param name="key">JKeyValuePair identation.</param>
 /// <returns></returns>
 public JKeyValuePair FindPairByKey(JSingleValue key)
 {
     if (this.HasKeyOrValue() && this.ContainsKey(key))
     {
         return(this as JKeyValuePair);
     }
     else
     {
         if (Items != null)
         {
             JKeyValuePair pair = null;
             foreach (var i in this.Items)
             {
                 pair = i.FindPairByKey(key);
                 if (pair != null)
                 {
                     return(pair);
                 }
             }
         }
     }
     return(null);
 }
Пример #7
0
 public override bool ContainsKeyAndValueOf(JKeyValuePair of)
 {
     return(ContainsKeyAndValue(of.Key.ToString(), of.Value.ToString()));
 }
Пример #8
0
 public virtual bool ContainsKeyAndValueOf(JKeyValuePair of)
 {
     return(false);
 }