public void Handle(string input) { if (input.Length <= 0) { return; } string[] inputArr = input.Split(' '); string inputCommand = inputArr[0]; string[] inputArgs = RemoveCommandString(inputArr); foreach (Command comm in Commands) { if (inputArr[0].ToLower() == comm.CommandString) { if (comm.GetType() == typeof(CommandExit)) { ExitCommandOccurred.Invoke(this, new EventArgs()); } else { string output = string.Empty; if ((output = comm.Execute(inputArgs)) != string.Empty) { OutputReady.Invoke(this, new OutputReadyEventArgs(output)); } } return; } } OutputReady.Invoke(this, new OutputReadyEventArgs("Invalid command \"" + inputCommand + "\"!")); }
protected virtual void OnExitCommandOccurred(EventArgs e) { ExitCommandOccurred?.Invoke(this, e); }