private static void CanExecuteTest()
        {
            ICommand command = new SendCommand(from: "", to: "555888000", content: "Hello World!");

            if (command.CanExecute())
            {
                command.Execute();
            }

            command = new PrintCommand(content: "Hello World!");

            if (command.CanExecute())
            {
                command.Execute();
            }
        }
Beispiel #2
0
        private static void Main(string[] args)
        {
            var         taxiFunction = new TaxiFunction();
            TaxiCommand driveCommand = new DriveCommand(taxiFunction);
            TaxiCommand senCommand   = new SendCommand();
            TaxiCommand exitCommand  = new ExitCommand();

            var invoker = new TaxiInvoker();

            invoker.SetCommand(senCommand);
            invoker.ExecuteCommand();

            invoker.SetCommand(driveCommand);
            invoker.ExecuteCommand();

            invoker.SetCommand(exitCommand);
            invoker.ExecuteCommand();


            Console.ReadKey();
        }