コード例 #1
0
        static void Main(string[] args)
        {
            Tv             tv             = new Tv();
            CommandManager commandManager = new CommandManager();
            ActionFactory  actionFactory  = new ActionFactory(tv);

            commandManager.ExecuteCmd(actionFactory.Get(Status.On));

            commandManager.ExecuteCmd(actionFactory.Get(Status.Switch, 1));

            commandManager.ExecuteCmd(actionFactory.Get(Status.Switch, 2));

            commandManager.ExecuteCmd(actionFactory.Get(Status.Switch, 3));

            Console.WriteLine("current channel: " + tv.GetChannel());
            Console.WriteLine("\t undoing...");
            commandManager.Undo();

            Console.WriteLine("current channel: " + tv.GetChannel());
            Console.WriteLine("\t undoing...");
            commandManager.Undo();

            Console.WriteLine("current channel: " + tv.GetChannel());
            Console.WriteLine("\t redoing...");
            commandManager.Redo();

            Console.WriteLine("current channel: " + tv.GetChannel());
            Console.WriteLine("\t redoing...");
            commandManager.Redo();

            Console.WriteLine("current channel: " + tv.GetChannel());

            var off = actionFactory.Get(Status.Off);

            off.Execute();

            Console.ReadLine();
        }
コード例 #2
0
        public InteractAutomationElementResponse HandleInteractAutomationElementRequest(InteractAutomationElementRequest request)
        {
            var automationElementWrapper = _automationElementRepository.Get(request.WinDriverElementId);

            IExecutable executable = null;

            if (request.Action == Click || request.Action == DoubleClick || request.Action == ClickAtClickablePoint ||
                request.Action == GetText || request.Action == MoveMouse || request.Action == RightClick)
            {
                executable = ActionFactory.Get(request.Action, automationElementWrapper.AutomationElement);
            }

            if (request.Action == SendKeys)
            {
                executable = ActionFactory.Get(request.Action, automationElementWrapper.AutomationElement, request.Value);
            }

            return(new InteractAutomationElementResponse("Action was performed successfully", executable.Execute()));
        }
コード例 #3
0
        private async ValueTask <ActionRuleResult> ExecuteActionForRuleResult(RuleResultTree resultTree, bool includeRuleResults = false)
        {
            var triggerType = resultTree?.IsSuccess == true ? ActionTriggerType.onSuccess : ActionTriggerType.onFailure;

            if (resultTree?.Rule?.Actions != null && resultTree.Rule.Actions.ContainsKey(triggerType))
            {
                var actionInfo     = resultTree.Rule.Actions[triggerType];
                var action         = _actionFactory.Get(actionInfo.Name);
                var ruleParameters = resultTree.Inputs.Select(kv => new RuleParameter(kv.Key, kv.Value)).ToArray();
                return(await action.ExecuteAndReturnResultAsync(new ActionContext(actionInfo.Context, resultTree), ruleParameters, includeRuleResults));
            }
            else
            {
                //If there is no action,return output as null and return the result for rule
                return(new ActionRuleResult {
                    Output = null,
                    Results = includeRuleResults ? new List <RuleResultTree>()
                    {
                        resultTree
                    } : null
                });
            }
        }
コード例 #4
0
ファイル: BotViewModel.cs プロジェクト: nagyistge/RocketBot
 void ExecuteAddAction(BotActionType param)
 {
     UpcomingActions.Add(actionFactory.Get(param));
     Start.RaiseCanExecuteChanged();
     Stop.RaiseCanExecuteChanged();
 }