Пример #1
0
        public void Fill(int amount)
        {
            if (Content > Capacity)
            {
                Full?.Invoke(this, EventArgs.Empty);
                return;
            }

            int overflowed = 0;

            for (int i = 0; i <= amount; i++)
            {
                if (Content > Capacity)
                {
                    Overflowing?.Invoke(this, ++overflowed);
                }

                Content += 1;

                if (Content == Capacity)
                {
                    Full?.Invoke(this, EventArgs.Empty);
                }
            }

            if (overflowed > 0)
            {
                Overflowed?.Invoke(this, overflowed);
            }
        }
Пример #2
0
 void OverflowedChanged(object sender, EventArgs e)
 {
     Overflowed?.Invoke(this, e);
 }