public void Create_Bounded_Reference_StronglyTypedCommandParameter_MutableState() { IBoundedCommand <int> command = Command.Create <int>(_ => Task.CompletedTask, _ => false, 1); Assert.IsType <BoundedRelayCommand <int> >(command); Assert.False(command.CanExecute(240)); Assert.Equal(1, command.MaxCount); }
public void Create_Bounded_Reference_NoCommandParameter_MutableState() { IBoundedCommand command = Command.Create(() => Task.CompletedTask, () => false, 1); Assert.IsType <BoundedRelayCommand>(command); Assert.False(command.CanExecute()); Assert.Equal(1, command.MaxCount); }
public static async Task <bool> TryExecuteAsync(this IBoundedCommand command) { if (command.CanExecute()) { await command.ExecuteAsync(); return(true); } else { return(false); } }
public static async Task <bool> TryExecuteAsync <T>(this IBoundedCommand <T> command, T parameter) { if (command.CanExecute(parameter)) { await command.ExecuteAsync(parameter); return(true); } else { return(false); } }