Exemple #1
0
        internal static ICommand CreateOnceCommand(ref DelegateCommand command, Action executeMethod, Func <bool> canExecuteMethod, string name)
        {
            if (command == null)
            {
                if (executeMethod == null)
                {
                    throw new ArgumentNullException("executeMethod");
                }

                if (string.IsNullOrEmpty(name))
                {
                    name = executeMethod.Method.Name;
                }

                DelegateCommand.FuncExecute execute =
                    delegate
                {
                    executeMethod();
                };
                DelegateCommand.FuncCanExecute canExecute = null;
                if (canExecuteMethod != null)
                {
                    canExecute = delegate(object parameter)
                    {
                        return(canExecuteMethod());
                    };
                }
                command = new DelegateCommand(execute, canExecute, false, name);
            }
            return(command);
        }
Exemple #2
0
 internal static ICommand CreateOnceCommand(ref DelegateCommand command, DelegateCommand.FuncExecute execute, DelegateCommand.FuncCanExecute canExecute, string name)
 {
     if (command == null)
     {
         command = new DelegateCommand(execute, canExecute, false, name);
     }
     return(command);
 }
Exemple #3
0
 internal static ICommand CreateOnceCommand(ref DelegateCommand command, DelegateCommand.FuncExecute execute, DelegateCommand.FuncCanExecute canExecute)
 {
     return(CreateOnceCommand(ref command, execute, canExecute, null));
 }