我将尝试使用RestSharp GitHub wiki上的文档来实现对我的REST API服务的调用,但是我在特别是ExecuteAsync方法方面遇到了问题。
目前我的API类代码如下:
我知道这与GitHub页面上的内容略有不同,但我正在使用WP7,并且认为示例是针对C#的,因此使用ExecuteAsync方法。
我的问题是ExecuteAsync命令应该包含什么。我不能使用
目前我的API类代码如下:
public class HarooApi
{
const string BaseUrl = "https://domain.here";
readonly string _accountSid;
readonly string _secretKey;
public HarooApi(string accountSid, string secretKey)
{
_accountSid = accountSid;
_secretKey = secretKey;
}
public T Execute<T>(RestRequest request) where T : new()
{
var client = new RestClient();
client.BaseUrl = BaseUrl;
client.Authenticator = new HttpBasicAuthenticator(_accountSid, _secretKey);
request.AddParameter("AccountSid", _accountSid, ParameterType.UrlSegment);
client.ExecuteAsync<T>(request, (response) =>
{
return response.Data;
});
}
}
我知道这与GitHub页面上的内容略有不同,但我正在使用WP7,并且认为示例是针对C#的,因此使用ExecuteAsync方法。
我的问题是ExecuteAsync命令应该包含什么。我不能使用
return response.Data
,因为我收到了警告:'System.Action<RestSharp.RestResponse<T>,RestSharp.RestRequestAsyncHandle>' returns void, a return keyword must not be followed by an object expression
有人对如何修复这个问题有任何见解或者有可能帮助的教程吗?