コード例 #1
0
 /// <summary>
 /// Converts the specified <paramref name="source"/> to a paged data sequence initialized with <paramref name="settings"/>.
 /// </summary>
 /// <typeparam name="T">The type of the elements of <paramref name="source"/>.</typeparam>
 /// <param name="source">The source of the sequence to make pageable.</param>
 /// <param name="settings">The settings that specifies the conditions of the converted <paramref name="source"/>.</param>
 /// <param name="totalElementCount">The total number of elements in the <paramref name="source"/> sequence.</param>
 /// <returns>An instance of <see cref="PagedCollection{T}"/> initialized with <paramref name="settings"/>.</returns>
 public static PagedCollection <T> ToPagedCollection <T>(this IEnumerable <T> source, PagedSettings settings, int totalElementCount)
 {
     return(new PagedCollection <T>(source, settings, totalElementCount));
 }
コード例 #2
0
 /// <summary>
 /// Converts the specified <paramref name="source"/> to a paged data sequence initialized with <paramref name="settings"/>.
 /// </summary>
 /// <typeparam name="T">The type of the elements of <paramref name="source"/>.</typeparam>
 /// <param name="source">The source of the sequence to make pageable.</param>
 /// <param name="settings">The settings that specifies the conditions of the converted <paramref name="source"/>.</param>
 /// <returns>An instance of <see cref="PagedCollection{T}"/> initialized with <paramref name="settings"/>.</returns>
 public static PagedCollection <T> ToPagedCollection <T>(this IEnumerable <T> source, PagedSettings settings)
 {
     return(new PagedCollection <T>(source, settings));
 }
コード例 #3
0
        /// <summary>
        /// Retrieves all the elements in <paramref name="source"/> that match the conditions defined by the specified function delegate <paramref name="match"/>.
        /// </summary>
        /// <param name="source">The sequence to search and apply paging on.</param>
        /// <param name="match">The function delegate that defines the conditions of the elements to search for.</param>
        /// <param name="settings">The settings that specifies the conditions of the <paramref name="match"/> before applying paging to this instance.</param>
        /// <param name="comparison">One of the enumeration values that specifies the rules to use in the comparison.</param>
        /// <returns>A <see cref="PagedCollection{T}"/> that is the result of <paramref name="match"/>.</returns>
        public static PagedCollection <T> Search <T>(IEnumerable <T> source, Func <T, PagedSettings, StringComparison, bool> match, PagedSettings settings, StringComparison comparison)
        {
            Validator.ThrowIfNull(source, nameof(source));
            Validator.ThrowIfNull(match, nameof(match));
            Validator.ThrowIfNull(settings, nameof(settings));

            PagedCollection <T> pagedSource = source as PagedCollection <T>;

            return(new PagedCollection <T>(new List <T>(EnumerableUtility.FindAll(pagedSource == null ? source : pagedSource.OriginalSource, match, settings, comparison)), settings));
        }
コード例 #4
0
        /// <summary>
        /// Sort all the elements in <paramref name="source"/> by the <paramref name="settings"/> applied to the specified function delegate <paramref name="sorter"/>.
        /// </summary>
        /// <param name="source">The sequence to sort and apply paging on.</param>
        /// <param name="sorter">The function delegate that defines how the sorting is applied to the elements in <paramref name="source"/>.</param>
        /// <param name="settings">The settings that specifies the conditions of the <paramref name="sorter"/> before applying paging to this instance.</param>
        /// <returns>A <see cref="PagedCollection{T}"/> that is sorted by the specified <paramref name="sorter"/>.</returns>
        public static PagedCollection <T> Sort <T>(IEnumerable <T> source, Func <IEnumerable <T>, PagedSettings, IEnumerable <T> > sorter, PagedSettings settings)
        {
            Validator.ThrowIfNull(source, nameof(source));
            Validator.ThrowIfNull(sorter, nameof(sorter));
            Validator.ThrowIfNull(settings, nameof(settings));

            PagedCollection <T> pagedSource = source as PagedCollection <T>;

            return(new PagedCollection <T>(sorter(pagedSource == null ? source : pagedSource.OriginalSource, settings), settings));
        }
コード例 #5
0
 /// <summary>
 /// Retrieves all the elements in <paramref name="source"/> that match the conditions defined by the specified function delegate <paramref name="match"/>.
 /// </summary>
 /// <param name="source">The sequence to search and apply paging on.</param>
 /// <param name="match">The function delegate that defines the conditions of the elements to search for.</param>
 /// <param name="settings">The settings that specifies the conditions of the <paramref name="match"/> before applying paging to this instance.</param>
 /// <returns>A <see cref="PagedCollection{T}"/> that is the result of <paramref name="match"/>.</returns>
 /// <remarks>This search is performed by using a default value of <see cref="StringComparison.OrdinalIgnoreCase"/>.</remarks>
 public static PagedCollection <T> Search <T>(IEnumerable <T> source, Func <T, PagedSettings, StringComparison, bool> match, PagedSettings settings)
 {
     return(Search(source, match, settings, StringComparison.OrdinalIgnoreCase));
 }