示例#1
0
 /// <summary>
 /// Creates an enumerable traversing the tree starting with the given node.
 /// </summary>
 /// <typeparam name="TNode">The node base type used in the current tree. Inferred by the instance this method is called upon.</typeparam>
 /// <param name="root">The root node where to start the traversal.</param>
 /// <param name="match">The matching predicate. Enumeration will yield on every matching node.</param>
 /// <returns>An enumerable that can be used in foreach statements.</returns>
 public static IEnumerable <TNode> FindNodes <TNode>(this TNode root, Predicate <TNode> match)
     where TNode : class, INode
 {
     return(new SceneNodeEnumerable <TNode, TNode, IComponent> {
         _match = match, _rootList = VisitorHelpers.SingleRootEnumerator(root)
     });
 }
示例#2
0
 /// <summary>Finds all nodes containing one or more components matching a given search predicate within a tree of nodes.</summary>
 /// <typeparam name="TComponentToFind">The type of the components to find.</typeparam>
 /// <typeparam name="TNode">The type of nodes making up the tree.</typeparam>
 /// <typeparam name="TComponent">The base type of components used in the given hierarchy.</typeparam>
 /// <param name="root">The root node where to start the search.</param>
 /// <param name="match">The search predicate. Typically specified as a Lambda expression.</param>
 /// <returns>All nodes containing matching components.</returns>
 public static IEnumerable <TNode> FindNodesWhereComponent <TComponentToFind, TNode, TComponent>(this TNode root, Predicate <TComponentToFind> match)
     where TComponentToFind : class, TComponent
     where TNode : class, INode
     where TComponent : class, IComponent
 {
     return(new SceneNodeWhereComponentEnumerable <TComponentToFind, TNode, TComponent> {
         _match = match, _rootList = VisitorHelpers.SingleRootEnumerator(root)
     });
 }