private static string BuildLinkHeader(HttpRequestMessage request, PaginationInfo pi)
 {
     var path = request.RequestUri.AbsolutePath;
     var buffer = new List<string>();
     if (NeedsNextPage(pi))
     {
         buffer.Add(
             string.Format(
                 CultureInfo.InvariantCulture,
                 "next: <{0}?page={1}&pageSize={2}>",
                 path,
                 pi.Page + 1,
                 pi.PageSize));
     }
     if (NeedsPreviousPage(pi))
     {
         buffer.Add(
             string.Format(
                 CultureInfo.InvariantCulture,
                 "previous: <{0}?page={1}&pageSize={2}>",
                 path,
                 pi.Page - 1,
                 pi.PageSize));
     }
     if (NeedsLastPage(pi))
     {
         buffer.Add(
             string.Format(
                 CultureInfo.InvariantCulture,
                 "last: <{0}?page={1}&pageSize={2}>",
                 path,
                 pi.TotalPages,
                 pi.PageSize));
     }
     return string.Join("; ", buffer.ToArray());
 }
 private static string BuildXPaginationHeader(PaginationInfo pi)
 {
     return JsonConvert.SerializeObject(pi, Formatting.None);
 }
 private static bool NeedsNextPage(PaginationInfo pi)
 {
     return pi.Page < pi.TotalPages;
 }
 private static bool NeedsPreviousPage(PaginationInfo pi)
 {
     return pi.Page > 1;
 }
 private static bool IsLastPage(PaginationInfo pi)
 {
     return pi.Page >= pi.TotalPages;
 }
 private static bool NeedsLastPage(PaginationInfo pi)
 {
     return NeedsNextPage(pi) && !IsLastPage(pi);
 }