protected void HandleListAllPublicRepositoriesResponse(ListAllPublicRepositoriesRequest request, HttpWebResponse webResponse) { int status = (int) webResponse.StatusCode; var responseStream = webResponse.GetResponseStream (); DataContractJsonSerializer serializer = null; if (status == 200 && request.On200 != null) { serializer = new DataContractJsonSerializer (typeof(Repository[])); Repository[] result = (Repository[]) serializer.ReadObject (responseStream); request.On200(result); } else if(request.OnOther != null) { request.OnOther(webResponse); } }
public void ListAllPublicRepositories(ListAllPublicRepositoriesRequest request) { try { var uri = request.CreateUri(BaseUrl); var webRequest = CreateRequest (uri); webRequest.Method = "GET"; webRequest.UserAgent = "DotNet-GithubAPI"; var webResponse = (HttpWebResponse) webRequest.GetResponse (); HandleListAllPublicRepositoriesResponse(request, webResponse); } catch(WebException webException) { var webResponse = (HttpWebResponse) webException.Response; HandleListAllPublicRepositoriesResponse(request, webResponse); } catch(Exception exception) { throw; } }