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); }
public static void RaiseCanExecuteCommandChanged(this NotificationReflectorModel @this, in string propertyIndex)
private protected void SubscribeCanExecuteCommand <TAny>(NotificationReflectorModel model, string propertyName, ICommand command) { bool raiseFunc(string cmdName) => _cmdProvider.RaiseRelayGenericCommand <TAny>(cmdName); this.SubscribeCanExecuteCommandInternal(model, propertyName, command, raiseFunc); }