public int Next(int sequence, int step) { if (step < MIN_STEP || step > MAX_STEP) { throw new ArgumentOutOfRangeException("step", step, string.Format("should less between {0} and {1}.", MIN_STEP, MAX_STEP)); } SequenceRange range; if (!cache.TryGetValue(sequence, out range)) { lock (LockObject) { if (!cache.TryGetValue(sequence, out range)) { range = new SequenceRange(sequence); cache[sequence] = range; } } } return range.Next(step, this.SequenceRepository); }
public int Next(int sequence, int step = 1) { if (step < MIN_STEP || step > MAX_STEP) { throw new ArgumentOutOfRangeException("step", step, string.Format("should less between {0} and {1}.", MIN_STEP, MAX_STEP)); } SequenceRange range; if (!cache.TryGetValue(sequence, out range)) { lock (LockObject) { if (!cache.TryGetValue(sequence, out range)) { range = new SequenceRange(sequence); cache[sequence] = range; } } } return(range.Next(step, this.SequenceRepository)); }