-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathRelayPatternDescriptor.cs
More file actions
43 lines (35 loc) · 1.46 KB
/
RelayPatternDescriptor.cs
File metadata and controls
43 lines (35 loc) · 1.46 KB
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
using System;
using System.Windows.Automation;
namespace VisualUiaVerify.Integration
{
public class RelayPatternDescriptor : IUiaVerifyPatternDescriptor
{
private readonly Func<object, object> _descObjFactory;
public bool IsCommon { get; private set; }
public int Id { get; private set; }
public string DisplayName { get; private set; }
public RelayPatternDescriptor(AutomationPattern pattern, bool isCommon, Func<object, object> descObjFactory)
: this(CleanName(pattern.ProgrammaticName), pattern.Id, isCommon, descObjFactory)
{
}
private static string CleanName(string programmaticName)
{
const string ending = "PatternIdentifiers.Pattern";
if (programmaticName.EndsWith(ending))
return programmaticName.Remove(programmaticName.Length - ending.Length);
return programmaticName;
}
public RelayPatternDescriptor(string displayName, int id, bool isCommon, Func<object, object> descObjFactory)
{
DisplayName = displayName;
Id = id;
IsCommon = isCommon;
_descObjFactory = descObjFactory;
}
public bool TryGetPatternInstanceDescribingObject(object patternInstance, out object descriptor)
{
descriptor = _descObjFactory(patternInstance);
return descriptor != null;
}
}
}