/
OrSearchCondition.cs
50 lines (41 loc) · 1.39 KB
/
OrSearchCondition.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System.Linq;
using System.Runtime.Serialization;
using System.Windows.Automation;
namespace TestStack.White.UIItems.Finders
{
[DataContract]
public class OrSearchCondition : SearchCondition
{
[DataMember]
private readonly SimpleSearchCondition[] simpleSearchConditions;
private OrSearchCondition(){}
public OrSearchCondition(SimpleSearchCondition[] simpleSearchConditions)
{
this.simpleSearchConditions = simpleSearchConditions;
}
public override bool Satisfies(AutomationElement element)
{
return simpleSearchConditions.Any(c => c.Satisfies(element));
}
public override Condition AutomationCondition
{
get { return new OrCondition(simpleSearchConditions.Select(c => c.AutomationCondition).ToArray()); }
}
public override string ToString()
{
return string.Format("({0})", string.Join(" or ", simpleSearchConditions.Select(c => c.ToString())));
}
internal override string ToString(string operation)
{
return ToString();
}
protected internal override object SearchValue
{
get { return null; }
}
public override bool AppliesTo(AutomationElement element)
{
return simpleSearchConditions.Any(c => c.AppliesTo(element));
}
}
}