Beispiel #1
0
    /// <summary>
    /// Initializes a new instance of the <see cref="HiLoGenerator"/> class
    /// by using the given next high delegate and max lo value.
    /// </summary>
    /// <param name="next_high">
    /// A <see cref="CallableDelegate{T}"/> that is used to get the next High
    /// value.
    /// </param>
    public HiLoGenerator(NextHighDelegate next_high) {
      if (next_high == null) {
        throw new ArgumentNullException("next_high");
      }

      next_high_ = next_high;
      hi_lo_range_ = new FullHiloRange();
      lo_ = MaxHigh + 1;
    }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HiLoGenerator"/> class
        /// by using the given next high delegate and max lo value.
        /// </summary>
        /// <param name="next_high">
        /// A <see cref="CallableDelegate{T}"/> that is used to get the next High
        /// value.
        /// </param>
        public HiLoGenerator(NextHighDelegate next_high)
        {
            if (next_high == null)
            {
                throw new ArgumentNullException("next_high");
            }

            next_high_   = next_high;
            hi_lo_range_ = new FullHiloRange();
            lo_          = MaxHigh + 1;
        }
Beispiel #3
0
    /// <inheritdoc/>
    public virtual long Generate(string key) {
      if (key == null) {
        throw new ArgumentNullException("key");
      }

      if (lo_ > MaxHigh) {
        hi_lo_range_ = next_high_(key);
        lo_ = 0;
      }
      return hi_lo_range_.High + lo_++;
    }
Beispiel #4
0
        /// <inheritdoc/>
        public virtual long Generate(string key)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }

            if (lo_ > MaxHigh)
            {
                hi_lo_range_ = next_high_(key);
                lo_          = 0;
            }
            return(hi_lo_range_.High + lo_++);
        }