private void OnError(GitHubException obj) { }
private void LogError(GitHubException obj) { }
private GitHubRequestAsyncHandle CallApiAsync <TGitHubResponse, TRestResponse>( GitHubRequest request, Func <TRestResponse, TGitHubResponse> responseFactory, Func <IRestClient, IRestRequest, Action <TRestResponse, RestRequestAsyncHandle>, RestRequestAsyncHandle> restClientExecFunc, Action <TGitHubResponse> callback, Action <GitHubException> onError) where TGitHubResponse : IGitHubResponse where TRestResponse : IRestResponse { Requires.ArgumentNotNull(request, "request"); Requires.ArgumentNotNull(callback, "callback"); Requires.ArgumentNotNull(onError, "onError"); var restRequest = new RestRequest { Resource = request.Resource, Method = request.Method.ToRestSharpMethod(), RequestFormat = DataFormat.Json, JsonSerializer = new JsonSerializer() }; foreach (var p in request.Parameters) { restRequest.AddParameter(p.Name, p.Value); } #if WINDOWS_PHONE if (restRequest.Method == RestSharp.Method.GET) { // The implementation of HttpWebRequest in WP7 automatically caches all // all responses. Therefore, we add a query param with a unique value // to each request to ensure that we always GET fresh data. // see http://bit.ly/e3JNzE restRequest.AddParameter("ngithub_wp7_nocache", DateTime.UtcNow.Ticks); } #endif if (request.Body != null) { restRequest.AddBody(request.Body); } var baseUrl = (request.Version == API.v3) ? Constants.ApiV3Url : Constants.ApiV2Url; var restClient = _factory.CreateRestClient(baseUrl); restClient.Authenticator = Authenticator; var handle = restClientExecFunc( restClient, restRequest, (r, h) => { var response = responseFactory(r); GitHubException ex = null; if (_processor.TryProcessResponseErrors(response, out ex)) { onError(ex); return; } callback(response); }); return(new GitHubRequestAsyncHandle(request, handle)); }