3

私はRESTSharpを使用してRESTスタイルのサービスを利用しています。このライブラリはかなり新しく、RestSharpを使用してページングを実装する方法についてのガイダンスをいただければ幸いです。

これを達成する方法に関する既存の例はありますか?

RestSharp- http: //restsharp.org/

ありがとう

4

1 に答える 1

5

RestSharpに固有のページングの概念はありません。これはHTTP呼び出しの単なる薄いラッパーであるため、ページングの処理方法など、使用可能な機能を決定するのは、呼び出しているHTTPエンドポイントです。

ページングをサポートするAPIの例と、RestSharpを使用して呼び出す方法を次に示します。

public CallResult ListCalls(CallListRequest options, int pageNumber, int count)
{
    var request = new RestRequest();
    request.Resource = "Accounts/{AccountSid}/Calls.json";

    request.AddParameter("From", options.From);
    request.AddParameter("To", options.To);
    request.AddParameter("Url", options.Url);

    // send paging parameters required by API
    request.AddParameter("Page", pageNumber);
    request.AddParameter("PageSize", count);

    var client = new RestClient("http://example.com");
    return client.Execute<CallResult>(request);
}
于 2012-02-06T18:02:53.873 に答える