Beispiel #1
0
        private static Condition ParseProperty(string name, object value)
        {
            switch (name.ToLowerInvariant())
            {
            case "name":
                return(new PropertyCondition2(AutomationElement.NameProperty, (string)value));

            case "controltype":
                return(new PropertyCondition2(AutomationElement.ControlTypeProperty, NameMappings.GetType((string)value)));

            case "controlpattern":
                return(new PropertyCondition2(NameMappings.GetPatternPresenceProperty(NameMappings.GetPattern((string)value)), true));

            case "id":
                return(new PropertyCondition2(AutomationElement.AutomationIdProperty, (string)value));

            case "classname":
                return(new PropertyCondition2(AutomationElement.ClassNameProperty, (string)value));

            case "enabled":
                return(new PropertyCondition2(AutomationElement.IsEnabledProperty, (bool)value));

            case "value":
                return(new PropertyCondition2(ValuePattern.ValueProperty, (string)value));

            default:
                throw new ArgumentOutOfRangeException("name", name, "Unknown condition");
            }
        }