internal async Task SelectChild()

in Forge.TreeWalker/src/TreeWalkerSession.cs [522:545]


        internal async Task<string> SelectChild(TreeNode treeNode)
        {
            if (treeNode.ChildSelector == null)
            {
                // No children to select, we are done walking the tree.
                return null;
            }

            foreach (ChildSelector cs in treeNode.ChildSelector)
            {
                // Empty expressions default to true. Otherwise, evaluate the expression.
                if (string.IsNullOrWhiteSpace(cs.ShouldSelect) && !string.IsNullOrWhiteSpace(cs.Child))
                {
                    return cs.Child;
                }
                if ((bool)await this.EvaluateDynamicProperty(cs.ShouldSelect, typeof(bool)).ConfigureAwait(false))
                {
                    return cs.Child;
                }
            }

            // No children were successfully matched.
            throw new NoChildMatchedException("ChildSelector couldn't match any child.");
        }