Beispiel #1
0
        public SharePointPaginatedList(IEnumerable <T> source, int itemTotal, int pageNumber, int pageSize,
                                       string currentPageToken, string previousPageToken, string nextPageToken)
        {
            ParameterValidator.AssertIsNotNull("source", source);
            ParameterValidator.AssertIsPositiveValue("pageNumber", pageNumber);
            ParameterValidator.AssertIsPositiveValue("pageSize", pageSize);

            Items             = source;
            ItemTotal         = itemTotal;
            PageNumber        = pageNumber;
            PageSize          = pageSize;
            CurrentPageToken  = currentPageToken;
            PreviousPageToken = previousPageToken;
            NextPageToken     = nextPageToken;
        }
Beispiel #2
0
        public PaginatedList(IQueryable <T> source, int pageNumber, int pageSize, string orderByFieldName, bool orderAscending)
        {
            ParameterValidator.AssertIsNotNull("source", source);
            ParameterValidator.AssertIsPositiveValue("pageNumber", pageNumber);
            ParameterValidator.AssertIsPositiveValue("pageSize", pageSize);
            ParameterValidator.AssertIsNotNullOrWhiteSpace("orderByFieldName", orderByFieldName);

            ItemTotal = source.Count();

            string methodName = orderAscending ? "OrderBy" : "OrderByDescending";
            IOrderedQueryable <T> sortedList = ApplySort(source, orderByFieldName, methodName);

            Items = sortedList.Skip((pageNumber - 1) * pageSize).Take(pageSize).ToList();

            PageNumber = pageNumber;
            PageSize   = pageSize;
        }
Beispiel #3
0
        public static int IndexOf(this string[] haystack, string needle, StringComparison comparer)
        {
            ParameterValidator.AssertIsNotNull("haystack", haystack);

            int indexOf = -1;

            for (int i = 0; i < haystack.Length; i++)
            {
                if (String.Equals(haystack[i], needle, comparer))
                {
                    indexOf = i;
                    break;
                }
            }

            return(indexOf);
        }