Exemple #1
0
        protected void HandleListUserRepositoriesResponse(ListUserRepositoriesRequest 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);
            }
        }
Exemple #2
0
        public void ListUserRepositories(ListUserRepositoriesRequest request)
        {
            try {
                var uri = request.CreateUri(BaseUrl);
                var webRequest = CreateRequest (uri);
                webRequest.Method = "GET";
                webRequest.UserAgent = "DotNet-GithubAPI";

                var webResponse = (HttpWebResponse) webRequest.GetResponse ();
                HandleListUserRepositoriesResponse(request, webResponse);
            }
            catch(WebException webException) {
                var webResponse = (HttpWebResponse)  webException.Response;
                HandleListUserRepositoriesResponse(request, webResponse);
            }
            catch(Exception exception) {
                throw;
            }
        }