Beispiel #1
0
        public static PagedList <T> BuildUsingPagedList <TSource>(PagedList <TSource> source)
        {
            var result = new PagedList <T>
            {
                _paginationStats = PaginationStats.FromPaginationStats(source._paginationStats)
            };

            return(result);
        }
Beispiel #2
0
        public static PaginationStats SinglePage(int count)
        {
            var result = new PaginationStats();

            result._totalNumberOfItems = result._pageSize = count;
            result._pageNumber         = result._totalNumberOfPages = result._firstItemIndex = 1;

            return(result);
        }
Beispiel #3
0
        public static PagedList <T> BuildUsingStartIndex(int totalNumberOfItems, int pageSize, int startIndex)
        {
            var result = new PagedList <T>
            {
                _paginationStats = PaginationStats.FromStartIndex(totalNumberOfItems, pageSize, startIndex)
            };

            return(result);
        }
Beispiel #4
0
        public static PagedList <T> BuildUsingPageNumber(int totalNumberOfItems, int pageSize, int pageNumber)
        {
            var result = new PagedList <T>
            {
                _paginationStats = PaginationStats.FromPageNumber(totalNumberOfItems, pageSize, pageNumber)
            };

            return(result);
        }
Beispiel #5
0
        public static PagedList <T> BuildFromCompleteList(List <T> allItems)
        {
            var result = new PagedList <T>
            {
                PageItems        = allItems,
                _paginationStats = PaginationStats.SinglePage(allItems.Count)
            };

            return(result);
        }
Beispiel #6
0
        public static PaginationStats FromPaginationStats(PaginationStats source)
        {
            var result = new PaginationStats
            {
                _totalNumberOfItems = source._totalNumberOfItems,
                _pageSize           = source._pageSize,
                _totalNumberOfPages = source._totalNumberOfPages,
                _firstItemIndex     = source._firstItemIndex,
                _pageNumber         = source._pageNumber
            };

            return(result);
        }
Beispiel #7
0
        public static PaginationStats FromStartIndex(int totalNumberOfItems, int pageSize, int startIndex)
        {
            var result = new PaginationStats
            {
                _totalNumberOfItems = totalNumberOfItems,
                _pageSize           = pageSize,
                _totalNumberOfPages = (totalNumberOfItems + pageSize - 1) / pageSize,
                _firstItemIndex     = Math.Max(Math.Min(startIndex, totalNumberOfItems), 1),
                _pageNumber         = (startIndex + pageSize - 2) / pageSize + 1
            };

            return(result);
        }
Beispiel #8
0
        public static PaginationStats FromPageNumber(int totalNumberOfItems, int pageSize, int pageNumber)
        {
            var result = new PaginationStats
            {
                _totalNumberOfItems = totalNumberOfItems,
                _pageSize           = pageSize,
                _totalNumberOfPages = (totalNumberOfItems + pageSize - 1) / pageSize
            };

            result._pageNumber     = Math.Max(Math.Min(pageNumber, result._totalNumberOfPages), 1);
            result._firstItemIndex = (result._pageNumber - 1) * result._pageSize + 1;

            return(result);
        }
Beispiel #9
0
 public PagedList(List <T> allItems)
 {
     PageItems        = allItems;
     _paginationStats = PaginationStats.SinglePage(allItems.Count);
 }
Beispiel #10
0
 public PagedList(int totalNumberOfItems, int pageSize, int pageNumber)
 {
     _paginationStats = PaginationStats.FromPageNumber(totalNumberOfItems, pageSize, pageNumber);
 }