RemoveTask Class

Removes the specified task from a tree of tasks.
Inheritance Hierarchy
SystemObject
  Aspose.Tasks.UtilRemoveTask

Namespace:  Aspose.Tasks.Util
Assembly:  Aspose.Tasks (in Aspose.Tasks.dll) Version: 20.10
Syntax
public class RemoveTask : ITreeAlgorithm<Task>

The RemoveTask type exposes the following members.

Constructors
  NameDescription
Public methodCode exampleRemoveTask
Initializes a new instance of the RemoveTask class.
Methods
  NameDescription
Public methodCode exampleAlg
Do nothing.
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodCode examplePostAlg
Do nothing.
Public methodCode examplePreAlg
Removes the task from the specified parent task.
Public methodToString (Inherited from Object.)
Examples
Shows how to use <see cref="Aspose.Tasks.Util.RemoveTask" /> tree based algorithm.
public void WorkWithRemoveTask()
{
    var project = new Project(DataDir + "Project1.mpp");
    var task1 = project.RootTask.Children.Add("1");
    var task2 = project.RootTask.Children.Add("2");
    var task3 = project.RootTask.Children.Add("3");
    var task4 = project.RootTask.Children.Add("4");

    List<Task> tasks = new List<Task>(project.RootTask.SelectAllChildTasks());
    Console.WriteLine("Number of tasks before using the algorithm: " + tasks.Count);
    foreach (var task in project.RootTask.SelectAllChildTasks())
    {
        Console.WriteLine("Task Name: " + task.Get(Tsk.Name));
    }

    Console.WriteLine();

    // use tree based algorithm to delete task1 from the tree
    var algorithm = new RemoveTask(task1);

    // apply the algorithm to the task tree
    TaskUtils.Apply(project.RootTask, algorithm, 0);

    // check the results
    tasks = new List<Task>(project.RootTask.SelectAllChildTasks());
    Console.WriteLine("Number of tasks after using the algorithm: " + tasks.Count);
    foreach (var task in project.RootTask.SelectAllChildTasks())
    {
        Console.WriteLine("Task Name: " + task.Get(Tsk.Name));
    }

    // ...
}
See Also