protected virtual void OnPriceChanged(PriceChangedEventArgs e)
 {
     if (e.NewPrice > 200)
     {
         PriceChanged.Invoke(this, e); // removed null check because the object is already initialized.
     }
 }
Example #2
0
 private void OnPriceUpdate()
 {
     PriceChanged?.Invoke(this, new PriceUpdateEventArgs()
     {
         Row = Row, AlertId = Alerts.IndexOf(this)
     });
 }
Example #3
0
 protected virtual void OnPriceChanged(EventArgs e)
 {
     if (PriceChanged != null)
     {
         PriceChanged.Invoke(this, e);
     }
 }
Example #4
0
        //методы
        public void ChangePrice(int value)
        {
            Price = value;
            var args = new PriceChangedEventArgs();

            args.NewPrice = value;
            PriceChanged?.Invoke(this, args);
        }
Example #5
0
        private void RecalculatePrice()
        {
            CafeItemInfo.TotalPrice = ItemCheckbox.Checked
                ? CafeItemInfo.Price * CafeItemInfo.Count
                : 0;

            PriceChanged?.Invoke(this, CafeItemInfo.TotalPrice);
        }
Example #6
0
 public void OnPriceChange(PriceChangedEventAgrs e)
 {
     PriceChanged?.Invoke(this, e);
     //if (PriceChanged != null)
     //{
     //    PriceChanged(this, e);
     //}
 }
Example #7
0
 protected virtual void OnPriceChanged(PriceChangedEventArgs e)
 {
     //when there is method is added to PriceChanged event delegate
     if (PriceChanged != null)
     {
         //invoke the method:
         //   stock_PriceChanged(object sender, PriceChangedEventArgs e)
         PriceChanged.Invoke(this, e);
     }
 }
Example #8
0
        /// <summary>
        /// Simulates a change in stock price. Rules are:
        /// 1) New price is within -/+ 10 % of the current price.
        /// 2) New price must be at most equal to upper limit.
        /// 3) New price must be at least equal to lower limit.
        /// </summary>
        public void GenerateNewPrice()
        {
            int    percentChange = 10 - _generator.Next(21);
            double factor        = 1 + (percentChange / 100.0);

            double newPrice = _price * factor;

            if (newPrice > _upperLimit)
            {
                newPrice = _upperLimit;
            }

            if (newPrice < _lowerLimit)
            {
                newPrice = _lowerLimit;
            }

            Price = newPrice;
            PriceChanged?.Invoke(ID, Price);
        }
        public event EventHandler <PriceChangedEventArgs> PriceChanged; // 2 & 3 Use Framework define generic delegate

        protected virtual void OnPriceChanged(PriceChangedEventArgs e)  // Protected Virtual Method that fires the event
        {
            PriceChanged?.Invoke(this, e);
        }
Example #10
0
 protected virtual void OnPriceChanged(PriceChangedEventArgs e)
 {
     PriceChanged?.Invoke(this, e);
 }
Example #11
0
 // The Standard Event Pattern requires a protected virtual method that fires the event.
 // The name has to match the name of the event, prefixed with the word "On".
 // It has to accept a single EventArgs argument
 protected virtual void OnPriceChanged(PriceChangedEventArgs e)
 {
     // This is a thread-safe and succint way to envoke the event.
     PriceChanged?.Invoke(this, e);
 }
Example #12
0
 private void OnPriceChanged(decimal pretVechi, decimal pretNou) //functie care aplica delegatul cand trebuie
 {
     PriceChanged?.Invoke(this, new PriceChangedArgs {
         PretNou = pretNou, PretVechi = pretVechi
     });
 }
Example #13
0
 private void OnMatch(object sender, RealtimeMatch e)
 {
     this.Price = e.Price.Value;
     PriceChanged?.Invoke(this, e.Price.Value);
 }
Example #14
0
 void OnPriceChanged(int priceChange)
 {
     PriceChanged?.Invoke(this, priceChange);
 }
Example #15
0
 public void ChangePrice(float price)
 {
     Price = price;
     PriceChanged?.Invoke(this, price);
 }
        public event EventHandler <PriceChangedEventArgs> PriceChanged; // "Po zdefiniowaniu podklasy klasy EventArgs jest wybór lub zdefiniowanie delegatu dla zdarzenia"

        //public event EventHandler PriceChanged;

        protected virtual void OnPriceChanged(PriceChangedEventArgs e) // "I w końcu wzorzec zakłada napisanie chronionej metody wirtualnej uruchamiającej zdarzenie."
        {
            PriceChanged?.Invoke(this, e);
        }
Example #17
0
 public void Test()
 {
     PriceChanged?.Invoke(this, new PriceChangedEventArgs(1, 1));
 }
Example #18
0
            // any method inside of Stock class can call the event, which then triggers subscribers

            protected virtual void OnPriceChanged(PriceChangedEventArgs e)
            {
                PriceChanged?.Invoke(this, e); // null propagation, will check for null before invocation
            }