public void Run <TContext>(ITaskTreeNode <TContext> taskTreeNode, TContext context)
 {
     foreach (var currentTaskTreeNode in TaskTreeNode.EnumerateAll(taskTreeNode))
     {
         currentTaskTreeNode.Task.Consume(context);
     }
 }
        public static IEnumerable <ITaskTreeNode <TContext> > EnumerateAll <TContext>(ITaskTreeNode <TContext> taskTreeNode)
        {
            yield return(taskTreeNode);

            if (!taskTreeNode.IsLeaf())
            {
                foreach (var child in taskTreeNode.Children)
                {
                    var childTaskTreeNodes = TaskTreeNode.EnumerateAll(child);
                    foreach (var subChild in childTaskTreeNodes)
                    {
                        yield return(subChild);
                    }
                }
            }
        }
        public static bool IsLeaf <TContext>(ITaskTreeNode <TContext> taskTreeNode)
        {
            var isLeaf = Object.ReferenceEquals(taskTreeNode.Children, TaskTreeNode <TContext> .LeafChildren);

            return(isLeaf);
        }
Exemple #4
0
        public static bool IsLeaf <TContext>(this ITaskTreeNode <TContext> taskTreeNode)
        {
            var isLeaf = TaskTreeNode.IsLeaf(taskTreeNode);

            return(isLeaf);
        }
        public static TTaskContext AddTask <TTaskContext, TContext>(this TTaskContext taskContext, ITaskTreeNode <TContext> taskTreeNode)
            where TTaskContext : ITaskContext <TContext>
        {
            taskContext.Branch.AddChild(taskTreeNode);

            return(taskContext);
        }
Exemple #6
0
 public void AddChild(ITaskTreeNode <TContext> child)
 {
     this.Children.Add(child);
 }