Esempio n. 1
0
        /// <summary>
        /// Breadth First search of the document tree
        /// </summary>
        public JsonValue FindValueByKey(string key, eTraversalStrategy strategy = eTraversalStrategy.BreadthFirst, eTraversalFlowDirection direction = eTraversalFlowDirection.ThroughChildren)
        {
            JsonValue found = TreeTraversal <JsonValue> .GetFirstChildWhichPasses(this, _TestIsDocumentWithKey, direction, strategy);

            if (found != null)
            {
                return(((JsonDocument)found).ValueFor(key));
            }

            return(null);

            bool _TestIsDocumentWithKey(JsonValue value)
            {
                return(value.IsDocument && ((JsonDocument)value).ContainsKey(key));
            }
        }
Esempio n. 2
0
        public void TreeTraversal_CanFindChild()
        {
            var foundTreePart = TreeTraversal <TestTreePart> .GetFirstChildWhichPasses(root, node => node == a_b_c);

            Assert.AreSame(a_b_c, foundTreePart);
        }