示例#1
0
        private protected void UnsubscribeCanExecuteCommand(NotificationReflectorModel model, string propertyName)
        {
            var guaranteedCommandName = model.GetKeyCommand(propertyName);

            _cmdProvider.RemoveCommand(guaranteedCommandName);

            model.CanExecuteCommandChanged -= _subscribersDictionary[guaranteedCommandName];

            _subscribersDictionary.Remove(guaranteedCommandName);
        }
示例#2
0
        private void SubscribeCanExecuteCommandInternal(NotificationReflectorModel model, string propertyName, ICommand command, Func <string, bool> raiseFunc)
        {
            var guaranteedCommandName = model.GetKeyCommand(propertyName);

            _cmdProvider.AddCommand(guaranteedCommandName, command);

            CommandChangedEventHandler handler = (objectSender, commandName) =>
            {
                var result = raiseFunc.Invoke(commandName);

                if (!result)
                {
                    raiseFunc.Invoke(guaranteedCommandName);
                }
            };

            model.CanExecuteCommandChanged += handler;

            _subscribersDictionary.Add(guaranteedCommandName, handler);
        }