FilterCriteria

FilterCriteria class

Defines the criteria that tasks or resources must meet to be displayed in MSP view.

public class FilterCriteria

Constructors

NameDescription
FilterCriteria()The default constructor.

Properties

NameDescription
CriteriaRows { get; }Gets the list of child FilterCriteria rows. If the filter contains more than one criterion row then the effect of an And operator is that the criteria for both rows must be met for the task or resource to be displayed as a result of this filter. The effect of an Or operator is that the criteria for one or the other row must be met.
Field { get; set; }Gets or sets a Field to change.
Operation { get; set; }Gets or sets the criterion established with FieldName, Test, and Value relates to other criteria in the filter.
Test { get; set; }Gets or sets the type of comparison made between FieldName and Value that acts as selection criteria for the filter. FilterComparisonType
Values { get; }Gets the object values to compare with the value of the field specified with FieldName.

Methods

NameDescription
IsFieldValue()Gets whether the right-hand value of FilterCriteria is a field reference, not a constant value.
SetValueField(Field)Sets the field whose value will be compared with the value of the field specified by FieldName.
override ToString()Returns string representation of the instance of the FilterCriteria class.

Examples

Shows how to read task filter criteria.

var project = new Project(DataDir + "Project2003.mpp");

var filter = project.TaskFilters.ToList()[1];
Console.WriteLine("Count of criteria rows: " + filter.Criteria.CriteriaRows.Count);
foreach (var row in filter.Criteria.CriteriaRows)
{
    Console.WriteLine("Field: " + row.Field);
    Console.WriteLine("Operation: " + row.Operation);
    Console.WriteLine("Test: " + row.Test);

    var values = row.Values.Where(c => c != null).ToArray();
    if (values.Length == 0)
    {
        continue;
    }

    Console.WriteLine("Value{0}: {1}", values.Length == 1 ? "" : "s", string.Join(", ", values));
}

// print filter criteria as a string 
Console.WriteLine(filter.Criteria.Operation.ToString());

var criteria1 = filter.Criteria.CriteriaRows[0];
Console.WriteLine("Criteria filter 1:");
Console.WriteLine(criteria1.ToString());

var criteria2 = filter.Criteria.CriteriaRows[1];
Console.WriteLine(criteria2.Operation.ToString());
Console.WriteLine(criteria2.CriteriaRows.Count);
Console.WriteLine("Criteria filter 2:");
Console.WriteLine(criteria2.ToString());

var criteria21 = criteria2.CriteriaRows[0];
Console.WriteLine("Criteria filter 21:");
Console.WriteLine(criteria21.ToString());

var criteria22 = criteria2.CriteriaRows[1];
Console.WriteLine("Criteria filter 22:");
Console.WriteLine(criteria22.ToString());

See Also