private protected void UnsubscribeCanExecuteCommand(NotificationReflectorModel model, string propertyName) { var guaranteedCommandName = model.GetKeyCommand(propertyName); _cmdProvider.RemoveCommand(guaranteedCommandName); model.CanExecuteCommandChanged -= _subscribersDictionary[guaranteedCommandName]; _subscribersDictionary.Remove(guaranteedCommandName); }
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); }