Esempio n. 1
0
        static void Main(string[] args)
        {
            EventBroket broker = new EventBroket();
            Car         volvo  = new Car(broker);

            broker.ExecuteCommand(new SwitchLights(volvo, true));
            broker.ExecuteCommand(new SwitchLights(volvo, false));
            broker.ExecuteCommand(new SwitchLights(volvo, true));

            foreach (var item in broker.AllEvents)
            {
                Console.WriteLine(item);
            }

            var result = broker.ExecuteQuery <string>(new GetLightsStatus());

            Console.WriteLine($"Current status {result}");
        }
Esempio n. 2
0
 public Car(EventBroket broker)
 {
     this.broker          = broker;
     this.broker.Command += SwitchLights;
     this.broker.Query   += GetLightsStatus;
 }