public override IMvxCommand ToCommand(object owner) { var executeAction = new Action(() => ExecuteMethodInfo.Invoke(owner, new object[0])); Func <bool> canExecuteFunc = null; if (CanExecutePropertyInfo != null) { canExecuteFunc = () => (bool)CanExecutePropertyInfo.GetValue(owner, null); } return(new MvxCommand(executeAction, canExecuteFunc)); }
public override IMvxCommand ToCommand(object owner) { var executeAction = new Action <object>((obj) => ExecuteMethodInfo.Invoke(owner, new[] { obj })); Func <object, bool> canExecuteFunc = null; if (CanExecutePropertyInfo != null) { canExecuteFunc = (ignored) => (bool)CanExecutePropertyInfo.GetValue(owner, null); } return(new MvxCommand <object>(executeAction, canExecuteFunc)); }
public override IMvxCommand ToCommand(object owner) { var executeAction = new Action(() => ExecuteMethodInfo.Invoke(owner, Array.Empty <object>())); Func <bool>?canExecuteFunc = null; if (CanExecutePropertyInfo != null) { canExecuteFunc = () => (bool)(CanExecutePropertyInfo.GetValue(owner, null) ?? true); } return(new MvxCommand(executeAction, canExecuteFunc)); }