Exemplo n.º 1
0
        private async Task FetchingPageSizeTask()
        {
            // Call the deriving class to get the information

            DataListPageResult <T> pageInfo = await FetchPageSizeAsync();

            Update(pageInfo);
        }
Exemplo n.º 2
0
        private async Task FetchingPageTask(int pageNumber)
        {
            // Call the deriving class to get the information

            DataListPageResult <T> pageInfo = await FetchPageAsync(pageNumber);

            Update(pageInfo);

            // Remove the fetching page task from the internal list so subsequent requests are reperformed

            fetchingPageTasks[pageNumber - 1] = null;
        }
Exemplo n.º 3
0
        private void Update(DataListPageResult <T> pageInfo)
        {
            // Update the total item count
            // TODO : Handle situation if the total item count has changed between calls! (raise collection changed & update internals?)

            if (pageInfo.TotalItemCount != null && count != pageInfo.TotalItemCount)
            {
                count = pageInfo.TotalItemCount;
            }

            // Update the items per page

            if (pageInfo.ItemsPerPage != null)
            {
                itemsPerPage = pageInfo.ItemsPerPage.Value;
            }

            // If we know both the item count and the items per page then...

            if (count != null && itemsPerPage != null)
            {
                // (a) Update the PageVirtualizingList with this information

                ////////////InternalList.UpdateCount(count.Value, itemsPerPage.Value);

                // (b) If the number of pages has changed then update the array for fetching page tasks

                int pageCount = (count.Value - 1) / itemsPerPage.Value + 1;

                if (fetchingPageTasks.Length < pageCount)
                {
                    Task[] newPageFetchingTasks = new Task[pageCount];
                    fetchingPageTasks.CopyTo(newPageFetchingTasks, 0);
                    fetchingPageTasks = newPageFetchingTasks;
                }
            }

            // Update the page information

            if (pageInfo.PageNumber != null)
            {
                int startIndex = itemsPerPage.Value * (pageInfo.PageNumber.Value - 1);

                for (int i = 0; i < pageInfo.Page.Count; i++)
                {
                    InternalList[startIndex + i] = pageInfo.Page[i];
                }
            }
        }