Esempio n. 1
0
        static void Main(string[] args)
        {
            CarFactory factory = new CarFactory();
             Consumer nick = new Consumer("Nick");
             factory.CarCreated += nick.NewCarArrived;

             factory.CreateACar("Ferrari");
             Consumer kimi = new Consumer("Kimi");
             factory.CarCreated += kimi.NewCarArrived;

             factory.CreateACar("BMW");

             factory.CarCreated -= nick.NewCarArrived;

             factory.CreateACar("Mercedes");
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            var dealer = new CarDealer();

              var michael = new Consumer("Michael");
              WeakEventManager<CarDealer, CarInfoEventArgs>.AddHandler(dealer, "NewCarInfo", michael.NewCarIsHere);

              dealer.NewCar("Mercedes");

              var sebastian = new Consumer("Sebastian");
              WeakEventManager<CarDealer, CarInfoEventArgs>.AddHandler(dealer, "NewCarInfo", sebastian.NewCarIsHere);

              dealer.NewCar("Ferrari");

              WeakEventManager<CarDealer, CarInfoEventArgs>.RemoveHandler(dealer, "NewCarInfo", michael.NewCarIsHere);

              dealer.NewCar("Red Bull Racing");
        }
Esempio n. 3
0
        static void Main()
        {
            var dealer = new CarDealer();

            var michael = new Consumer("Michael");
            WeakCarInfoEventManager.AddListener(dealer, michael);

            dealer.NewCar("Mercedes");

            var nick = new Consumer("Nick");
            WeakCarInfoEventManager.AddListener(dealer, nick);

            dealer.NewCar("Ferrari");

            WeakCarInfoEventManager.RemoveListener(dealer, michael);

            dealer.NewCar("Toyota");
            System.Console.ReadKey();
        }
Esempio n. 4
0
        static void Main()
        {
            var dealer = new CarDealer();

            var michael = new Consumer("Michael");
            dealer.NewCarInfo += michael.NewCarIsHere;

            dealer.NewCar("Mercedes");

            var nick = new Consumer("Nick");
            dealer.NewCarInfo += nick.NewCarIsHere;

            dealer.NewCar("Ferrari");

            dealer.NewCarInfo -= michael.NewCarIsHere;

            dealer.NewCar("Toyota");
            Console.ReadKey();
        }
Esempio n. 5
0
        static void Main()
        {
            var dealer = new CarDealer();

            var michael = new Consumer("Michael");
            dealer.NewCarInfo += michael.NewCarIsHere;

            dealer.NewCar("Ferrari");

            var nick = new Consumer("Sebastian");
            dealer.NewCarInfo += nick.NewCarIsHere;

            dealer.NewCar("Mercedes");

            dealer.NewCarInfo -= michael.NewCarIsHere;

            dealer.NewCar("Red Bull Racing");

            Console.ReadKey();
        }