public async Task <IIncrementalLoadResponse <TItem> > Fetch(int itemsToFetch)
        {
            // Calculate number of pages to retrieve
            int pagesToFetch = (int)Math.Ceiling((decimal)itemsToFetch / _pageSize);

            // Perform fetch
            IIncrementalLoadResponse <TItem> response = await DoDataFetch(_currentPage, pagesToFetch);

            // Update state
            _currentPage++;

            return(response);
        }
Esempio n. 2
0
        /// <summary>
        /// Effectively this implementation ignores count argument.
        /// It just loads another page of data if needed
        /// </summary>
        private async Task <LoadMoreItemsResult> PerformPageLoading(int count)
        {
            IIncrementalLoadResponse <TItem> response = await _incrementalLoadSource.Fetch(count);

            if (!_isInitialLoadDone)
            {
                _totalItemCount    = response.TotalItemCount;
                _isInitialLoadDone = true;
            }

            foreach (TItem item in response.Items)
            {
                this.Add(item);
            }

            LoadMoreItemsResult result =
                new LoadMoreItemsResult
            {
                Count = (uint)response.Items.Count()
            };

            return(result);
        }