Exemplo n.º 1
0
        public bool Equals(MessengerCommand <T> other)
        {
            bool result = execute == other.execute &&
                          canExecute == other.canExecute;

            return(result);
        }
Exemplo n.º 2
0
        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
                    });
                }
            }
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
                }
            }
        }
Exemplo n.º 5
0
        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);
                    }
                }
            }
        }