Added parameter check to Process method in CommandEngine.cs.

This commit is contained in:
Harrison Deng 2020-02-24 02:57:48 -05:00
parent fa74bc9ae5
commit 92f302875f

View File

@ -34,6 +34,9 @@ namespace RecrownedGTK.Tools.CommandProcessor
public void Process(IUserInput userInput, IUserOutput userOutput, string commandAndArguments) public void Process(IUserInput userInput, IUserOutput userOutput, string commandAndArguments)
{ {
if (userInput == null || userOutput == null || commandAndArguments == null) {
throw new ArgumentNullException("No arguments should be null.");
}
string command = commandAndArguments; string command = commandAndArguments;
string[] arguments = null; string[] arguments = null;
@ -75,6 +78,11 @@ namespace RecrownedGTK.Tools.CommandProcessor
GetCommand(command).Run(userInput, userOutput, arguments); GetCommand(command).Run(userInput, userOutput, arguments);
} }
/// <summary>
/// Check if the command exists using it's invokes string.
/// </summary>
/// <param name="command">A string that will invoke the command.</param>
/// <returns></returns>
public bool ContainsCommand(string command) public bool ContainsCommand(string command)
{ {
for (int i = 0; i < commands.Count; i++) for (int i = 0; i < commands.Count; i++)