コード例 #1
0
ファイル: SequenceService.cs プロジェクト: yonglehou/ace-1
        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);
        }
コード例 #2
0
ファイル: SequenceService.cs プロジェクト: hotjk/dotconfig
        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));
        }