-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #115 from 2gis/114-automation-properties
Add support of AutomationProperties to GetElementAttribute
- Loading branch information
Showing
8 changed files
with
150 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
Winium/Winium.StoreApps.InnerServer/Element/Helpers/AutomationPropertiesAccessor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
namespace Winium.StoreApps.InnerServer.Element.Helpers | ||
{ | ||
#region | ||
|
||
using Windows.UI.Xaml; | ||
|
||
#endregion | ||
|
||
internal static class AutomationPropertiesAccessor | ||
{ | ||
#region Public Methods and Operators | ||
|
||
public static bool TryGetAutomationProperty(FrameworkElement element, string propertyName, out object value) | ||
{ | ||
value = null; | ||
DependencyProperty property; | ||
if (!AutomationPropertiesHelper.Instance.TryGetAutomationProperty(propertyName, out property)) | ||
{ | ||
return false; | ||
} | ||
|
||
value = element.GetValue(property); | ||
return true; | ||
} | ||
|
||
#endregion | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
Winium/Winium.StoreApps.InnerServer/Element/Helpers/AutomationPropertiesHelper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
namespace Winium.StoreApps.InnerServer.Element.Helpers | ||
{ | ||
#region | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
|
||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Automation; | ||
|
||
#endregion | ||
|
||
internal class AutomationPropertiesHelper | ||
{ | ||
#region Static Fields | ||
|
||
private static readonly Lazy<AutomationPropertiesHelper> LazyInstance = | ||
new Lazy<AutomationPropertiesHelper>(() => new AutomationPropertiesHelper()); | ||
|
||
#endregion | ||
|
||
#region Fields | ||
|
||
private readonly Dictionary<string, DependencyProperty> properties; | ||
|
||
#endregion | ||
|
||
#region Constructors and Destructors | ||
|
||
private AutomationPropertiesHelper() | ||
{ | ||
this.properties = typeof(AutomationProperties).GetRuntimeProperties() | ||
.ToDictionary(f => f.Name, f => (DependencyProperty)f.GetValue(null)); | ||
} | ||
|
||
#endregion | ||
|
||
#region Public Properties | ||
|
||
public static AutomationPropertiesHelper Instance | ||
{ | ||
get | ||
{ | ||
return LazyInstance.Value; | ||
} | ||
} | ||
|
||
#endregion | ||
|
||
#region Public Methods and Operators | ||
|
||
public bool TryGetAutomationProperty(string name, out DependencyProperty property) | ||
{ | ||
return this.properties.TryGetValue(name, out property); | ||
} | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters