public bool Equals(MessengerCommand <T> other) { bool result = execute == other.execute && canExecute == other.canExecute; return(result); }
public void MultiRegister <T>(CommandName commandType, Action <T> execute, Func <T, bool> canExecute) where T : class { ICommand command = new MessengerCommand <T>(execute, canExecute); if (commands.ContainsKey(commandType)) { OnBusinessLogicException(commandType); } else { if (multiCommands.ContainsKey(commandType)) { if (multiCommands[commandType].All(x => !command.Equals(x))) { multiCommands[commandType].Add(command); } } else { multiCommands.Add(commandType, new List <ICommand> { command }); } } }
public override bool Equals(object other) { MessengerCommand <T> messengerCommand = other as MessengerCommand <T>; bool result = false; if (messengerCommand != null) { result = this.Equals(messengerCommand); } return(result); }
public void Register <T>(CommandName commandType, Action <T> execute, Func <T, bool> canExecute) where T : class { ICommand command = new MessengerCommand <T>(execute, canExecute); if (multiCommands.ContainsKey(commandType)) { OnBusinessLogicException(commandType); } else { if (commands.ContainsKey(commandType)) { commands[commandType] = command; } else { commands.Add(commandType, command); } } }
public void MultiUnregister <T>(CommandName commandType, Action <T> execute, Func <T, bool> canExecute) where T : class { if (commands.ContainsKey(commandType)) { OnBusinessLogicException(commandType); } else { MessengerCommand <T> command = new MessengerCommand <T>(execute, canExecute); if (multiCommands.ContainsKey(commandType) && multiCommands[commandType] != null) { multiCommands[commandType].RemoveAll(x => command.Equals(x)); if (!multiCommands[commandType].Any()) { MultiUnregister(commandType); } } } }