Automation.UI.Util.ConditionHelper.IsMeetsRequirements C# (CSharp) Метод

IsMeetsRequirements() публичный статический Метод

Check to see if the specified automation element meets the requirements of the specified condition.
public static IsMeetsRequirements ( Condition condition, AutomationElement element ) : bool
condition Condition The condition to check.
element System.Windows.Automation.AutomationElement The automation element to check.
Результат bool
        public static bool IsMeetsRequirements(Condition condition, AutomationElement element)
        {
            var type = condition.GetType();
            if (condition == Condition.TrueCondition)
                // Always return true.
                return true;
            if (condition == Condition.FalseCondition)
                // Always returns false.
                return false;
            if (type == typeof(NotCondition))
                // Return the negation of the inner condition.
                return !IsMeetsRequirements(((NotCondition) condition).Condition, element);
            if (type == typeof(OrCondition))
                // Return true if any of the inner conditions are true.
                return ((OrCondition) condition).GetConditions().Any(inner => IsMeetsRequirements(inner, element));
            if (type == typeof(AndCondition))
                // Return true if all of the inner conditions are true.
                return ((AndCondition) condition).GetConditions().All(inner => IsMeetsRequirements(inner, element));
            if (type == typeof(StringPropertyCondition))
                // Return true if the string property condition matches.
                return ((StringPropertyCondition) condition).IsMatch(element);
            if (type == typeof(PropertyCondition)) {
                // Return true if the property condition matches.
                var propertyCondition = (PropertyCondition) condition;
                var actual = element.GetCurrentPropertyValue(propertyCondition.Property);
                var expected = propertyCondition.Value;

                Trace.WriteLine("Checking '" + AutomationPropertyHelper.ToString(actual) + "'='" + AutomationPropertyHelper.ToString(expected) + "'", "UIAutomation-ConditionHelper");
                return AutomationPropertyHelper.Equals(actual, expected);
            }
            // Don't know how to match any other conditions.
            throw new NotSupportedException("Condition '" + type + "' is not supported");
        }