コード例 #1
0
        public async Task <bool> PowerOn()
        {
            var sendCommand       = new PowerOnCommand();
            var tlSerialPortAsync = new TLAutoDeviceSerialPortAsync <bool>(TLAutoDeviceSerialPort, sendCommand, null, _logModuleName, _timeOutMs);

            return(await tlSerialPortAsync.InvokeAsync());
        }
コード例 #2
0
        static void Main(string[] args)
        {
            ISwitchable switcher = new LightSwitcher();

            ICommand on  = new PowerOnCommand(switcher);
            ICommand off = new PowerOffCommand(switcher);

            var invoker = new SwitchInvoker(on, off);

            Console.WriteLine("Lights ON =>");
            invoker.LightOn();
            Console.WriteLine();
            Console.WriteLine("Lights OFF =>");
            invoker.LightOff();
            Console.WriteLine();
            Console.ReadKey();
        }