Exemplo n.º 1
0
        private static bool Test(GPNode node, GPNodeGatherer filter)
        {
            if (node == null || filter == null)
            {
                return(false);
            }

            // use the GPNodeGatherer if available
            return(filter.Test(node));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Return this node and its descendants filtered by the GPNodeGatherer.
 /// </summary>
 public static IEnumerable <GPNode> Descendants(this GPNode node, GPNodeGatherer gatherer)
 {
     if (node != null)
     {
         if (Test(node, gatherer))
         {
             yield return(node);
         }
         if (node.Children != null)
         {
             foreach (GPNode child in node.Children.Descendants())
             {
                 if (Test(child, gatherer))
                 {
                     yield return(child);
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Enumerates filtered GPNodes in the tree starting with the root (tree.Child).
 /// Results are filtered by the GPNodeGatherer which tests each node to decide
 /// if it qualifies.
 /// </summary>
 public static IEnumerable <GPNode> Descendants(this GPTree tree, GPNodeGatherer gatherer)
 {
     return(Descendants(tree.Child, gatherer));
 }