示例#1
0
        static void Main(string[] args)
        {
            Task copySecurity = new Backup();
            Task antivirus    = new Antivirus();

            ICommand StartBackUp = new StartBackUpCommand(copySecurity);
            ICommand StopBackUp  = new StopBackUpCommand(copySecurity);

            ICommand StartAntivirusCommand = new StartAntivirusCommand(antivirus);
            ICommand StopAntivirusCommand  = new StopAntivirusCommand(antivirus);

            IInvoker TaskPlanner = new TaskPlanner();

            TaskPlanner.SetCommand(StartBackUp);
            TaskPlanner.Invoke();
            TaskPlanner.SetCommand(StopBackUp);
            TaskPlanner.Invoke();
            Console.WriteLine("\n");
            TaskPlanner.SetCommand(StartAntivirusCommand);
            TaskPlanner.Invoke();
            TaskPlanner.SetCommand(StopAntivirusCommand);
            TaskPlanner.Invoke();

            Console.ReadKey();
        }