public void Run() { _forceStop = false; Index = 0; while (Index < Commands.Length) { if (_forceStop) { break; } var command = Commands[Index]; Execute(command); OnCommandExecuted?.Invoke(); Index += 1; } if (_forceStop) { OnProgramStopped?.Invoke(); } else { OnProgramFinished?.Invoke(); } }
private object ExecuteCommand(ICommand command) { object returnValue = CommandProcessor.Execute(command); OnCommandExecuted?.Invoke(this, null); return(returnValue); }
public void RunCommand <TCommand>(TCommand cmd) where TCommand : UnitCommandBase { Assert.IsNotNull(cmd); cmd.Execute(); OnCommandExecuted?.Invoke(cmd); }
public void Redo() { if (CommandProcessor.CanRedo) { CommandProcessor.Redo(); } OnCommandExecuted?.Invoke(this, null); }
/// <summary> /// Processes a context generated from whatever service you are providing commands for. /// It will parse the message, check if it is a command, find the correct command and execute it. /// </summary> /// <param name="ctx">The context created by you from a message from the service you're providing commands for.</param> public async Task ProcessMessageAsync(TContext ctx) { if (ctx.Message.StartsWith(Prefix)) { var parsedCommand = Parser.ParseContext(ctx, PrefixLength); var commandMatch = _matcher.MatchCommand(RegisteredModules, parsedCommand); var result = _execution.ExecuteCommand(commandMatch, parsedCommand); await result.Item1; OnCommandExecuted?.Invoke(this, result.Item2); } }
public void ExecuteCommand(string command, List <string> args) { if (!Commands.ContainsKey(command)) { WriteLine("Invalid command."); return; } Commands[command]?.Invoke(args); OnCommandExecuted?.Invoke(command, Descriptions[command], args); }
public virtual void ExecuteCommand(ICapability capability, Command command) { if (capability == null || command == null) { return; } command.Execute(capability); OnCommandExecuted?.Invoke(capability, command); EventManager.UnitCommandExecuted(this, capability, command); }
private void ExecuteCommand(Command command) { OnCommandExecuting?.Invoke(this, new CommandEventArgs(command)); switch (command.Action.ToLowerInvariant()) { case "click": GetElement(command.Target).Click(); break; case "open": if (!string.Equals(_driver.Url, command.Target)) { string target = null; if (command.Target.StartsWith("http://") || command.Target.StartsWith("https://")) { target = command.Target; } else { var uri = new Uri(_driver.Url); target = command.Target.StartsWith("/") ? $"{uri.Scheme}://{uri.Host}{target}" : $"{uri.Scheme}://{uri.Host}/{command.Target}"; } _driver.Navigate().GoToUrl(target); } break; case "sendkeys": case "type": var element = GetElement(command.Target); if (string.IsNullOrEmpty(command.Value)) { element.Clear(); } else { element.SendKeys(command.Value); } break; case "setwindowsize": var dimensions = command.Target.Split('x'); _driver.Manage().Window.Size = new System.Drawing.Size(int.Parse(dimensions[0]), int.Parse(dimensions[1])); break; case "waitforelementpresent": _ = GetElement(command.Target, string.IsNullOrWhiteSpace(command.Value) || !int.TryParse(command.Target, out var timeout) ? null : TimeSpan.FromMilliseconds(timeout) as TimeSpan?); break; } OnCommandExecuted?.Invoke(this, new CommandEventArgs(command)); }
void CommandExecuted() { this.ReplEditor.OnCommandExecuted(); OnCommandExecuted?.Invoke(this, EventArgs.Empty); }
public static void TriggerOnCommandExecuted(SocketUserMessage msg, SocketUser user, string commandname, string[] parameters) { OnCommandExecuted?.Invoke(msg, user, commandname, parameters); }
internal static void RunCommandExecute(PointBlankCommand command, string[] args, Player.PointBlankPlayer executor, ref bool allowExecute) { OnCommandExecuted?.Invoke(command, args, executor, ref allowExecute); }