Я пытаюсь использовать документацию в RestSharp GitHub wiki для реализации вызовов моей службы REST API, но у меня проблема с использованием метода 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 и считаю, что пример для С# - это использование метода 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
Есть ли у кого-нибудь представление о том, как исправить это или учебник, который может помочь?