예제 #1
0
        public async void GetItemsItemOffsetPagination()
        {
            string endPoint = "http://MyRestApiEndPoint.com";
            var maxRecordsParam = 20;
            var offsetParemeterName = "offset";
            var pageSizeParemeterName = "limit";
            var orderByParameterName = "order_by";
            var orderByParameterValue = "date";
            var orderDirectionParameterName = "order";
            var orderDirectionParameterValue = "DESC";


            var paginationConfig = new ItemOffsetPagination(offsetParemeterName, true, pageSizeParemeterName, maxRecordsParam)
            {
                OrderByParameterName = orderByParameterName,
                OrderByParameterValue = orderByParameterValue,
                OrderDirectionParameterName = orderDirectionParameterName,
                OrderDirectionParameterValue = orderDirectionParameterValue
            };

            var config = new RestApiDataConfig()
            {
                Url = new Uri(endPoint),
                PaginationConfig = paginationConfig
            };

            var parser = new JsonParser<MySchema>();
            _dataProvider = new RestApiDataProvider();
            var items = await _dataProvider.LoadDataAsync(config, maxRecordsParam, parser);
            foreach (var item in items)
            {
                Items.Add(item);
            }
        }
예제 #2
0
        private IPagination GetPaginationConfig()
        {
            IPagination pagination = null;
            switch (PaginationParameterType)
            {
                case PaginationParameterType.PageNumber:
                    pagination = new PageNumberPagination(PaginationParameterName, IsZeroIndexed, PageSizeParameterName);
                    break;
                case PaginationParameterType.ItemOffset:
                    pagination = new ItemOffsetPagination(PaginationParameterName, IsZeroIndexed, PageSizeParameterName, MaxRecordsParam);
                    break;
                case PaginationParameterType.Token:
                    pagination = new TokenPagination(PaginationParameterName, ResponseTokenName, PageSizeParameterName);
                    break;
                case PaginationParameterType.NextPageUrl:
                    pagination = new NextPageUrlPagination(ResponseTokenName, PageSizeParameterName);
                    break;
                case PaginationParameterType.None:
                default:
                    return null;
            }

            pagination = GetSorting(pagination);
            return pagination;
        }