Esempio n. 1
0
        static void Main(string[] args)
        {
            Pult    invoker         = new Pult();
            TV      reciver         = new TV();
            Command concreteCommand = new Command(reciver);

            invoker.SetCommand(concreteCommand);
            invoker.PressButton();
            invoker.PressUndo();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Pult pult = new Pult();
            TV   tv   = new TV();

            pult.SetCommand(new TVOnCommand(tv));
            pult.PressButton();
            pult.PressUndo();

            Console.Read();
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            Pult pult = new Pult();
            TV   tv   = new TV();

            pult.SetCommand(new TVonCommand(tv));
            pult.PressButton(); //включение
            pult.PressUndo();   //выключение

            Console.ReadKey();
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            TV   tv   = new TV();
            Pult pult = new Pult(new TVOnCommand(tv));

            pult.PressDoButton();
            pult.PressUndoButton();
            Console.ReadKey();
            //pult can send any command to tv at the same time pult know nothing about just like tv
            //know nothing about pult
            //thus we have flexible system where all the commands are stored in one class
        }
Esempio n. 5
0
        public static void Main(string[] args)
        {
            // Объект пульта - инициатора комманды.
            Pult pult = new Pult();
            // Принимающая сторона комманды.
            TV tv = new TV();

            // Устанавливаем комманду и кому она будет отправляться.
            pult.SetCommand(new TVOnCommand(tv));
            // Через нашу абстракцию пульт посылаем команды, нашей абстракции телевизору.
            pult.PressButton();
            pult.PressUndo();

            Console.Read();
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            Pult pult = new Pult();
            TV   tv   = new TV();

            pult.SetCommand(new TVOnCommand(tv));
            pult.PressButton();
            pult.PressUndo();

            Microwave microwave = new Microwave();

            pult.SetCommand(new MicrowaveCommand(microwave, 5000));
            pult.PressButton();

            Console.Read();
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            var tv = new TV();
            var airConditioning = new AirConditioning();

            var tvOnCommand     = new TvOnCommand(tv);
            var airStartCommand = new AirConditioningStartCommand(airConditioning, 21d);

            var pult = new Pult
            {
                BlueBtnCommand = tvOnCommand,
                RedBtnCommand  = airStartCommand
            };

            pult.BlueBtnPress();
            pult.RedButtonPress();

            Console.ReadKey();
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            Pult pult = new Pult();
            TV   tv   = new TV();

            pult.SetCommand(new TVOnCommand(tv));
            pult.PressButton();
            pult.PressUndo();

            Microwave microwave = new Microwave();

            pult.SetCommand(new MicrowaveCommand(microwave, 5000));
            pult.PressButton();

            MacroCommand macro = new MacroCommand(new List <ICommand>()
            {
                new TVOnCommand(tv), new MicrowaveCommand(microwave, 5000)
            });

            pult.SetCommand(macro);
            pult.PressButton();
        }
Esempio n. 9
0
        /// <summary>
        /// The main.
        /// </summary>
        private static void Main()
        {
            var pult = new Pult();

            var deviceA = new DeviceA();

            pult.SetCommand(new OnAndOfCommand(deviceA));
            pult.ExecuteCommand();
            pult.RollBackCommand();

            pult.SetCommand(new SelfTesting(deviceA, "Test 1"));
            pult.ExecuteCommand();

            var deviceB = new DeviceB();

            pult.SetCommand(new OnAndOfCommand(deviceB));
            pult.ExecuteCommand();
            pult.RollBackCommand();

            pult.SetCommand(new SelfTesting(deviceB, "Test X"));
            pult.ExecuteCommand();

            Console.ReadLine();
        }