protected bool UnregisterCommand(ICommandParserEntity item) { var existingCommand = this.commandParser.GetRegisteredCommand(item.CommandKeyword, item.CommandChannel); if (existingCommand != null) { if (existingCommand != this.CommandImplementation()) { this.Logger.WarnFormat( "Could not unregister item {0} with command parser as this command is not the correct type.", item.CommandKeyword); return(false); } this.Logger.DebugFormat("Unregistered item {0} from command parser.", item.CommandKeyword); lock (this.registeredCommands) { this.registeredCommands.Remove(new CommandParserEntity(item)); } this.commandParser.UnregisterCommand(item.CommandKeyword, item.CommandChannel); } return(true); }
protected void RegisterCommand(ICommandParserEntity item) { if (!this.UnregisterCommand(item)) { return; } this.commandParser.RegisterCommand(item.CommandKeyword, this.CommandImplementation(), item.CommandChannel); lock (this.registeredCommands) { this.registeredCommands.Add(new CommandParserEntity(item)); } this.Logger.DebugFormat("Registered item {0} in command parser.", item.CommandKeyword); }
public CommandParserEntity(ICommandParserEntity fromOther) { this.CommandKeyword = fromOther.CommandKeyword; this.CommandChannel = fromOther.CommandChannel; }