private IEnumerable <PagerPageBase> PreviousPages(PagerContext pager)
        {
            yield return(pager.PageIndex == 0
                ? new PagerPageDisabled(LabelFirst, 1)
                : new PagerPage(LabelFirst, 1));

            yield return(pager.PreviousPage > 1
                ? new PagerPage(LabelPrevious, pager.MinPage - 1)
                : new PagerPageDisabled(LabelPrevious, pager.MinPage - 1));
        }
        private IEnumerable <PagerPageBase> NextPages(PagerContext pager)
        {
            yield return(pager.NextPage >= pager.MaxPage
                ? (PagerPageBase) new PagerPage(LabelNext, pager.MaxPage + 1)
                : new PagerPageDisabled(LabelNext, pager.MaxPage));

            yield return(pager.PageIndex + 1 == pager.TotalPages
                ? (PagerPageBase) new PagerPageDisabled(LabelLast, pager.TotalPages)
                : new PagerPage(LabelLast, pager.TotalPages));
        }
        private IEnumerable <PagerPageBase> GetNumberPages(PagerContext pager)
        {
            for (var i = pager.MinPage; i <= pager.MaxPage; i++)
            {
                if (i == pager.PageIndex + 1)
                {
                    yield return(new PagerPageActive(i.ToString(), i));

                    continue;
                }
                yield return(new PagerPage(i.ToString(), i));
            }
        }
        public List <PagerPageBase> GetPages(PagerContext pager)
        {
            var list = new List <PagerPageBase>();

            var firstAndPrev = PreviousPages(pager);

            list.AddRange(firstAndPrev);

            var pages = GetNumberPages(pager);

            list.AddRange(pages);

            var nextAndLast = NextPages(pager);

            list.AddRange(nextAndLast);

            return(list);
        }