示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        public static async Task <bool> TryExecuteAsync(this IBoundedCommand command)
        {
            if (command.CanExecute())
            {
                await command.ExecuteAsync();

                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#4
0
        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);
            }
        }