Beispiel #1
0
 protected virtual void OnCheckPrice(Product product)
 {
     PriceChecking?.Invoke(this, new PriceCheckEventArgs()
     {
         Product = product
     });
 }
Beispiel #2
0
            public event EventHandler <PriceCheckEventArgs> PriceChecking; // Define an event based on the delegate

            public void CheckPrice(Product product)
            {
                // Product type determines which service
                if (product.Type == 1)
                {
                    PriceChecking += service1.PriceChecking;
                    PriceChecking?.Invoke(this, new PriceCheckEventArgs()
                    {
                        Product = product
                    });                                                                           // Raise the event
                    PriceChecking -= service1.PriceChecking;
                }
                else
                {
                    PriceChecking += service2.PriceChecking;
                    PriceChecking?.Invoke(this, new PriceCheckEventArgs()
                    {
                        Product = product
                    });
                    PriceChecking -= service2.PriceChecking;
                }
            }