Пример #1
0
        /// <summary>
        /// Safely calls event.
        /// </summary>
        /// <param name="amountModifiedEventHandler">Event to call.</param>
        private static void CallEvent(AmountModifiedEventHandler amountModifiedEventHandler)
        {
            var handler = amountModifiedEventHandler;

            if (handler != null)
            {
                handler();
            }
        }
Пример #2
0
 /// <summary>
 /// Removes a callback from more than event dictionary at the given threshold.
 /// </summary>
 /// <param name="threshold">The threshold.</param>
 /// <param name="callback">The callback.</param>
 /// <param name="remove">Removes the event at the threshold key if true.</param>
 public void OffMoreThan(int threshold, AmountModifiedEventHandler callback, bool remove = true)
 {
     if (!moreThanEvents.ContainsKey(threshold))
     {
         return;
     }
     // ReSharper disable once DelegateSubtraction
     moreThanEvents[threshold] -= callback;
     if (remove)
     {
         moreThanEvents.Remove(threshold);
     }
 }
Пример #3
0
 /// <summary>
 /// Registers a callback to call when the value is more than the given threshold.
 /// </summary>
 /// <param name="threshold">The threshold.</param>
 /// <param name="callback">The callback.</param>
 public void OnMoreThan(int threshold, AmountModifiedEventHandler callback)
 {
     moreThanEvents.Add(threshold, null);
     moreThanEvents[threshold] += callback;
 }