public Command InterpretRequest(string command) { Command interpretation; if (command.Equals(TextCommands.SHOWREGISTERED, StringComparison.InvariantCultureIgnoreCase)) { interpretation = new CommandShowRegistered(); } else if (command.Equals(TextCommands.SHOWLOGGED, StringComparison.InvariantCultureIgnoreCase)) { interpretation = new CommandShowLogged(); } else if (command.Equals(TextCommands.STARTMATCH, StringComparison.InvariantCultureIgnoreCase)) { interpretation = new CommandStartMatch(); } else if (command.Equals(TextCommands.EXIT, StringComparison.InvariantCultureIgnoreCase)) { interpretation = new CommandExit(); } else { interpretation = new CommandUnknown(); } return(interpretation); }
public ICommand Parse(string command) { if (string.IsNullOrWhiteSpace(command)) { throw new ArgumentNullException("message", nameof(command)); } ICommand cmd = null; var cmdParts = command.Split(' ').ToList(); var cmdName = cmdParts[0]; var arguments = cmdParts.Skip(1).ToList(); switch (cmdName) { case Constant.ExitCommand: cmd = new CommandExit(); cmd.ParseArguments(arguments); break; case Constant.ParkCommand: cmd = new CommandPark(); cmd.ParseArguments(arguments); break; case Constant.HelpCommand: cmd = new CommandHelp(); break; default: return(null); } return(cmd); }
public void ExitRunTest() { CommandResult result = new CommandExit().Run(new List <string> { "" }); Assert.AreEqual(result.Errors[0], "exit"); Assert.Pass(); }
private void Process_Exited(object sender, EventArgs e) { try { System.IO.File.Delete(cmdFileName_); } catch { } if (CommandExit != null) { CommandExit.BeginInvoke(this, e, new AsyncCallback(CommandExitCallback), this); } }
public Command InterpretRequest(string command) { Command interpretation; if (command.Equals(TextCommands.REGISTER, StringComparison.InvariantCultureIgnoreCase)) { interpretation = new CommandRegister(); } else if (command.Equals(TextCommands.LOGIN, StringComparison.InvariantCultureIgnoreCase)) { interpretation = new CommandLogin(); } else if (command.Equals(TextCommands.LOGOUT, StringComparison.InvariantCultureIgnoreCase)) { interpretation = new CommandLogOut(); } else if (command.Equals(TextCommands.JOINMATCH, StringComparison.InvariantCultureIgnoreCase)) { interpretation = new CommandJoin(); } else if (command.Equals(TextCommands.SELECTCHARACTER, StringComparison.InvariantCultureIgnoreCase)) { interpretation = new CommandSelect(); } else if (command.Equals(TextCommands.MOVE, StringComparison.InvariantCultureIgnoreCase)) { interpretation = new CommandMove(); } else if (command.Equals(TextCommands.ATTACK, StringComparison.InvariantCultureIgnoreCase)) { interpretation = new CommandAttack(); } else if (command.Equals(TextCommands.EXIT, StringComparison.InvariantCultureIgnoreCase)) { interpretation = new CommandExit(); } else { interpretation = new CommandUnknown(); } return(interpretation); }
public void SetUp() { executor = new CommandExit(); }
private void CommandExitCallback(IAsyncResult ar) { CommandExit.EndInvoke(ar); }