/// <summary> /// Add _value to the current currency value. /// Call the Remove method if _value is negative. /// Fires the CurrencyManager events if _fireCallbacks is set to true. /// </summary> /// <param name="_value"></param> /// <param name="_fireCallbacks"></param> /// <returns>true if the _value has been successfully added</returns> public void Add(double _value, bool _fireCallbacks = true) { if (_value < 0) { Remove(-_value); return; } double intValue = _value - _value % 1; //Error if (currentValue + intValue) > double.MaxValue. Not worth checking it. currentAmount += intValue; currentAmount = Math.Min(currentAmount, maxAmount); if (_fireCallbacks) { OnCurrencyAdded?.Invoke(this); CurrencyChanged(); } }
private void OnCurrencyAddedInvoker(Currency _currency) { OnCurrencyAdded?.Invoke(_currency); }