AndAllConditionT Class

Applies logical AND to all conditions. For example: cond1 AND cond2 AND cond3...
Inheritance Hierarchy
SystemObject
  Aspose.Tasks.UtilAndAllConditionT

Namespace:  Aspose.Tasks.Util
Assembly:  Aspose.Tasks (in Aspose.Tasks.dll) Version: 20.10
Syntax
public class AndAllCondition<T> : ICondition<T>

Type Parameters

T
The type of object to apply method interface to.

The AndAllConditionT type exposes the following members.

Constructors
  NameDescription
Public methodCode exampleAndAllConditionT
Initializes a new instance of the AndAllConditionT class.
Methods
  NameDescription
Public methodCode exampleCheck
Returns true if the specified object satisfy the conditions.
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 methodToString (Inherited from Object.)
Examples
Shows how to use <see cref="Aspose.Tasks.Util.AndAllCondition`1" /> condition.
public void WorkWithAndAllCondition()
{
    var project = new Project(DataDir + "Project2.mpp");

    // gather all project tasks
    var coll = new ChildTasksCollector();
    TaskUtils.Apply(project.RootTask, coll, 0);

    var conditions = new List<ICondition<Task>>
                         {
                             // create a filter condition that filters not null tasks
                             new NotNullCondition(),

                             // create a filter condition that filters summary tasks
                             new SummaryCondition()
                         };

    // and join them by applying <see cref="Aspose.Tasks.Util.AndAllCondition`1" /> condition
    var joinedCondition = new AndAllCondition<Task>(conditions);

    // apply the condition to the collected tasks
    List<Task> collection = Filter(coll.Tasks, joinedCondition);
    Console.WriteLine("Filtered tasks: ");
    foreach (var task in collection)
    {
        Console.WriteLine("  Name: " + task.Get(Tsk.Name));

        // work with other properties...
    }

    // ...
}

private static List<T> Filter<T>(IEnumerable<T> array, ICondition<T> cond)
{
    var result = new List<T>();

    foreach (var item in array)
    {
        if (cond.Check(item))
        {
            result.Add(item);
        }
    }

    return result;
}

private class NotNullCondition : ICondition<Task>
{
    public bool Check(Task el)
    {
        return !el.Get(Tsk.IsNull).Value;
    }
}

private class SummaryCondition : ICondition<Task>
{
    public bool Check(Task el)
    {
        return el.Get(Tsk.IsSummary);
    }
}
See Also