Exemplo n.º 1
0
 /// <summary>
 /// Fix the parents after de desarlalized json
 /// </summary>
 /// <param name="task"></param>
 private void FixParents(DiscordTask task)
 {
     foreach (var child in task.Childs)
     {
         child.Parent = task;
         FixParents(child);
     }
 }
Exemplo n.º 2
0
 private void Print(DiscordTask task)
 {
     Console.WriteLine(task.GenerateLine());
     foreach (var child in task.Childs)
     {
         Print(child);
     }
 }
Exemplo n.º 3
0
        public static IEnumerable <DiscordTask> Descendants(this DiscordTask root)
        {
            var nodes = new Stack <DiscordTask>(new[] { root });

            while (nodes.Any())
            {
                DiscordTask node = nodes.Pop();
                yield return(node);

                foreach (var n in node.Childs)
                {
                    nodes.Push(n);
                }
            }
        }
Exemplo n.º 4
0
 public void RemoveTask(DiscordTask task)
 {
     task.Parent.Childs.Remove(task);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Adds a child to the node
 /// </summary>
 /// <param name="task"></param>
 public void AddTask(DiscordTask task)
 {
     task.Parent = this;
     task.Level  = this.Level + 1;
     this.Childs.Add(task);
 }