Exemplo n.º 1
0
        static FetchRowsResult FetchRows(FetchPageEventArgs e)
        {
            IssueSortOrder sortOrder = GetIssueSortOrder(e);
            IssueFilter    filter    = MakeIssueFilter(e.Filter);

            var issuesContext = (IssuesContext)e.Source;

            const int pageSize = 30;
            var       issues   = issuesContext.GetIssues(
                page: e.Skip / pageSize,
                pageSize: pageSize,
                sortOrder: sortOrder,
                filter: filter);

            return(new FetchRowsResult(issues, hasMoreRows: issues.Length == pageSize));
        }
Exemplo n.º 2
0
 static IssueSortOrder GetIssueSortOrder(FetchPageEventArgs e)
 {
     if (e.SortOrder.Length > 0)
     {
         var sort = e.SortOrder.Single();
         if (sort.PropertyName == "Created")
         {
             if (sort.Direction != ListSortDirection.Descending)
             {
                 throw new InvalidOperationException();
             }
             return(IssueSortOrder.CreatedDescending);
         }
         if (sort.PropertyName == "Votes")
         {
             return(sort.Direction == ListSortDirection.Ascending
                 ? IssueSortOrder.VotesAscending
                 : IssueSortOrder.VotesDescending);
         }
     }
     return(IssueSortOrder.Default);
 }