public void Create_Bounded_Value_StronglyTypedCommandParameter_MutableState() { IBoundedCommandSlim <int> command = Command.Create <int>(_ => new ValueTask(), _ => false, 1); Assert.IsType <BoundedRelayCommandSlim <int> >(command); Assert.False(command.CanExecute(240)); Assert.Equal(1, command.MaxCount); }
public void Create_Bounded_Value_NoCommandParameter_MutableState() { IBoundedCommandSlim command = Command.Create(() => new ValueTask(), () => false, 1); Assert.IsType <BoundedRelayCommandSlim>(command); Assert.False(command.CanExecute()); Assert.Equal(1, command.MaxCount); }
public static async ValueTask <bool> TryExecuteAsync <T>(this IBoundedCommandSlim <T> command, T parameter) { if (command.CanExecute(parameter)) { await command.ExecuteAsync(parameter); return(true); } else { return(false); } }
public static async ValueTask <bool> TryExecuteAsync(this IBoundedCommandSlim command) { if (command.CanExecute()) { await command.ExecuteAsync(); return(true); } else { return(false); } }