public RegisterCommand ( ICommand command, IViewModel viewModel = null ) : void | ||
command | ICommand | The command. |
viewModel | IViewModel | The view model. If specified, the command will automatically be unregistered when the view model is closed. |
return | void |
public void RegisterCommand(ICommand command, IViewModel viewModel = null)
{
Argument.IsNotNull("command", command);
lock (_lock)
{
var commandInfo = new CommandInfo(this, command, viewModel);
_commandInfo.Add(commandInfo);
command.CanExecuteChanged += OnCommandCanExecuteChanged;
Log.Debug("Registered command in CompositeCommand");
}
}
public void PreventsExecutionOfPartiallyExecutableCommand(bool checkCanExecuteOfAllCommandsToDetermineCanExecuteForCompositeCommand, bool expectedValue) { var compositeCommand = new CompositeCommand(); compositeCommand.RegisterCommand(new Command(() => { }, () => false)); compositeCommand.RegisterCommand(new Command(() => { }, () => true)); compositeCommand.CheckCanExecuteOfAllCommandsToDetermineCanExecuteForCompositeCommand = checkCanExecuteOfAllCommandsToDetermineCanExecuteForCompositeCommand; Assert.AreEqual(expectedValue, ((ICatelCommand)compositeCommand).CanExecute(null)); }