コード例 #1
0
 /// <summary>
 /// Defines a maximal count and a callback method to be triggered at
 /// counter exhaustion.
 /// </summary>
 /// <param name="max"> Maximal count. </param>
 /// <param name="cb"> Function to be called when the maximal count has been reached. </param>
 /// <exception cref="NullArgumentException"> if {@code cb} is {@code null} </exception>
 public Incrementor(int max, MaxCountExceededCallback cb)
 {
     if (cb == null)
     {
         throw new ArgumentNullException();
     }
     this.maximalcount     = max;
     this.maxCountCallback = cb;
 }
コード例 #2
0
 /// <summary>
 /// Defines a maximal count and a callback method to be triggered at
 /// counter exhaustion.
 /// </summary>
 /// <param name="max">Maximal count.</param>
 /// <param name="cb">Function to be called when the maximal count has been reached.</param>
 /// <exception cref="NullArgumentException"> if <c>cb</c> is <c>null</c></exception>
 public Incrementor(int max, MaxCountExceededCallback cb)
 {
     if (cb == null)
     {
         throw new NullArgumentException();
     }
     maximalCount     = max;
     maxCountCallback = cb;
 }
コード例 #3
0
 /// <summary>
 /// Defines a maximal count and a callback method to be triggered at
 /// counter exhaustion.
 /// </summary>
 /// <param name="max"> Maximal count. </param>
 /// <param name="cb"> Function to be called when the maximal count has been reached. </param>
 /// <exception cref="NullArgumentException"> if {@code cb} is {@code null} </exception>
 public Incrementor(int max, MaxCountExceededCallback cb = null)
 {
     cb = cb ?? new MaxCountExceededCallbackAnonymousInnerClass(this, max);
     if (cb == null)
     {
         throw new NullArgumentException();
     }
     maximalCount     = max;
     maxCountCallback = cb;
 }
コード例 #4
0
 /// <summary>
 /// Creates an incrementor.
 /// The counter will be exhausted either when {@code max} is reached
 /// or when {@code nTimes} increments have been performed.
 /// </summary>
 /// <param name="start"> Initial value. </param>
 /// <param name="max"> Maximal count. </param>
 /// <param name="step"> Increment. </param>
 /// <param name="cb"> Function to be called when the maximal count has been reached. </param>
 /// <exception cref="NullArgumentException"> if {@code cb} is {@code null}. </exception>
 internal Incrementor(int start, int max, int step, MaxCountExceededCallback cb)
 {
     if (cb == null)
     {
         throw new NullArgumentException();
     }
     this.init             = start;
     this.maximalCount     = max;
     this.increment        = step;
     this.maxCountCallback = cb;
     this.count            = start;
 }
コード例 #5
0
 /// <summary>
 /// Creates a new instance with a given callback.
 /// The counter is reset to the initial value.
 /// </summary>
 /// <param name="cb"> Callback to be called at counter exhaustion. </param>
 /// <returns> a new instance. </returns>
 public virtual Incrementor WithCallback(MaxCountExceededCallback cb)
 {
     return(new Incrementor(this.init, this.maximalCount, this.increment, cb));
 }
コード例 #6
0
 /// <summary>
 /// Defines a maximal count.
 /// </summary>
 /// <param name="max"> Maximal count. </param>
 public Incrementor(int max)
 {
     this.maximalcount     = max;
     this.maxCountCallback = new MaxCountExceededCallbackAnonymousInnerClassHelper(this, max);
 }