Пример #1
0
 public IReadOnlyList <PageNumberAndItemNumbers> AllPagesAndItemNumbers()
 {
     // The value may have already been initialized...
     return(this.AllPages ?? (this.CurrentPage.HasValue
                         ? PagingInfoCalculator.AllPagesAndItemNumbers(this)
                         : new PageNumberAndItemNumbers[0]));
 }
Пример #2
0
        /// <summary>
        /// Calculates the full set of page numbers and item
        /// numbers from given <paramref name="pageSize"/>
        /// and <paramref name="totalItems"/> values.
        /// </summary>
        /// <param name="pageSize">
        /// The <see cref="PageNumberAndSize.Size"/>
        /// of each page in a "paged" collection.
        /// </param>
        /// <param name="totalItems">
        /// The total number of items in a "paged" collection.
        /// </param>
        /// <returns>
        /// The full set of page numbers and item numbers.
        /// </returns>
        /// <remarks>
        /// Relays to the internal <see cref="PagingInfoCalculator.AllPagesAndItemNumbers(byte,int)"/>
        /// method of <see cref="PagingInfoCalculator"/>.
        /// </remarks>
        public static IReadOnlyList <PageNumberAndItemNumbers> Calculate(
            byte pageSize, int totalItems)
        {
            // Zero as page size is acceptable,
            // indicating a single "unbounded" page.
            Contract.Requires <ArgumentOutOfRangeException>(
                totalItems >= 0, "The number of items in the list must not be negative!");

            return(PagingInfoCalculator.AllPagesAndItemNumbers(pageSize, totalItems));
        }