private static object AutomationInvokeAction(FrameworkElement element)
        {
            var invokeProvider = element.GetProvider<IInvokeProvider>(PatternInterface.Invoke);
            invokeProvider.Invoke();

            return null;
        }
        private static object AutomationScrollAction(FrameworkElement element, IDictionary<string, JToken> parameters)
        {
            var scrollProvider = element.GetProvider<IScrollProvider>(PatternInterface.Scroll);

            var scrollInfo = parameters["args"].ElementAtOrDefault(1);
            if (scrollInfo == null)
            {
                var msg = string.Format(HelpArgumentsErrorMsg, HelpUrlAutomationScript);
                throw new AutomationException(msg, ResponseStatus.JavaScriptError);
            }

            var horizontalAmount = ParseScrollAmount(scrollInfo["horizontal"] ?? scrollInfo["h"]);
            var verticalAmount = ParseScrollAmount(scrollInfo["vertical"] ?? scrollInfo["v"]);
            var count = (scrollInfo["count"] ?? 1).Value<int>();

            if (horizontalAmount != ScrollAmount.NoAmount && !scrollProvider.HorizontallyScrollable)
            {
                throw new AutomationException("Element is not horizontally scrollable.", ResponseStatus.JavaScriptError);
            }

            if (verticalAmount != ScrollAmount.NoAmount && !scrollProvider.VerticallyScrollable)
            {
                throw new AutomationException("Element is not vertically scrollable.", ResponseStatus.JavaScriptError);
            }

            for (var i = 0; i < count; ++i)
            {
                scrollProvider.Scroll(horizontalAmount, verticalAmount);
            }

            return null;
        }
 private static string TogglePatternToggleState(FrameworkElement element)
 {
     var provider = element.GetProvider<IToggleProvider>(PatternInterface.Toggle);
     return provider.ToggleState.ToString();
 }
        private static object TogglePatternToggle(FrameworkElement element)
        {
            var provider = element.GetProvider<IToggleProvider>(PatternInterface.Toggle);
            provider.Toggle();

            return null;
        }