Esempio n. 1
0
        /// <summary>Finds a collection of all pages.</summary>
        /// <param name="instance">The instance of <see cref="IPaginator{T}"/> that provides the pages.</param>
        /// <param name="pageSize">The maximum number of page elements.</param>
        /// <param name="pageCount">The number of pages to get.</param>
        /// <typeparam name="T">The type of elements on the page.</typeparam>
        /// <exception cref="ArgumentNullException">The value of <paramref name="instance"/> is a null reference.</exception>
        /// <returns>A collection of pages.</returns>
        public static IEnumerable <Lazy <ICollectionPage <T> > > FindAllPages <T>(this IPaginator <T> instance, int pageSize, int pageCount)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }

            for (var pageIndex = 0; pageIndex < pageCount; pageIndex++)
            {
                var page = pageIndex;
                yield return(new Lazy <ICollectionPage <T> >(() => instance.FindPage(page, pageSize)));
            }
        }