Esempio n. 1
0
        private void ReOrder()
        {
            var index = 1;

            if (this._itens.HaveAny())
            {
                var current_index = this._current?.Index ?? 0;

                this._itens.OrderBy(o => o.Index).ToList().ForEach(i =>
                {
                    i.Index = index;

                    index++;
                });

                if (current_index > this._itens.Count - 1)
                {
                    this._current = this._itens[this._itens.Count - 1];
                }
                else
                {
                    this._current = this._itens[current_index];
                }
            }
        }
Esempio n. 2
0
        public void First()
        {
            if (this._itens.HaveAny())
            {
                var index = 1;

                var new_current = this._itens.Where(i => i.Index.Equals(index));

                if (new_current.HaveAny())
                {
                    this._current = new_current.First();
                }
            }
            else
            {
                this._current = null;
            }
        }
Esempio n. 3
0
        public void Add(string key)
        {
            var exists = this._itens.Where(i => i.Key.Equals(key)).HaveAny();

            if (!exists)
            {
                this._itens.Add(new RoundRobinDetail
                {
                    Index = this._itens.Count() + 1,
                    Key   = key
                });
            }

            if (this._itens.Count.Equals(1))
            {
                this._current = this._itens.First();
            }
        }
Esempio n. 4
0
        public void Previous()
        {
            if (this._itens.HaveAny())
            {
                var index = 0;

                if (this._current.Index.Equals(1))
                {
                    index = this._itens.Max(i => i.Index);
                }

                var new_current = this._itens.Where(i => i.Index.Equals(index - 1));

                if (new_current.HaveAny())
                {
                    this._current = new_current.First();
                }
            }
            else
            {
                this._current = null;
            }
        }