public static void RegisterCommand(ICommand command) { if (!(command is ISpell) && command.GetWords().Contains(' ')) throw new Exception("Command words cannot contain spaces."); LinkedListNode<ICommand> lastNode = commandList.First; if (lastNode == null) { commandList.AddFirst(command); } else { while (lastNode.Next != null && lastNode.Value.GetWords().Length > command.GetWords().Length) { lastNode = lastNode.Next; } commandList.AddAfter(lastNode, command); } }
public static void RegisterCommand(ICommand command) { if (!(command is ISpell) && command.GetWords().Contains(' ')) { throw new Exception("Command words cannot contain spaces."); } LinkedListNode <ICommand> lastNode = commandList.First; if (lastNode == null) { commandList.AddFirst(command); } else { while (lastNode.Next != null && lastNode.Value.GetWords().Length > command.GetWords().Length) { lastNode = lastNode.Next; } commandList.AddAfter(lastNode, command); } }