/// <summary>
        /// Performs a Get WebRequest to the specified URL and returns a collection of GithubJsonItems.
        /// </summary>
        /// <param name="uri">The url for the Get Request.</param>
        /// <returns></returns>
        private Collection <GithubJsonItem> Get(String uri)
        {
            Collection <GithubJsonItem> rtn = new Collection <GithubJsonItem>();

            ghc                   = (HttpWebRequest)WebRequest.Create(uri);
            ghc.UserAgent         = StringValue.psftitle;
            ghc.AllowAutoRedirect = true;
            WebResponse ghr = null;

            try
            {
                ghr = ghc.GetResponse();
            }
            catch (WebException wex)
            {
                ratelimitremaining = GetRateLimitRemaining(wex.Response);
                errors.Add(uri + ":" + wex.Message);
            }
            catch (Exception e)
            {
                errors.Add(uri + ":" + e.Message);
            }
            if (ghr != null)
            {
                ratelimitremaining = GetRateLimitRemaining(ghr);
                lastmodified       = GetLastModified(ghr);
                if (ghr.ContentType == StringValue.ContentTypeJSON)
                {
                    Stream ghrs = ghr.GetResponseStream();
                    if (ghrs != null)
                    {
                        StreamReader ghrdr    = new StreamReader(ghrs);
                        String       response = ghrdr.ReadToEnd();
                        ghrdr.Close();
                        ghrdr = null;
                        String   name  = "\"name\"";
                        String[] split = new string[] { "\"name\"" };
                        String[] items = response.Split(split, StringSplitOptions.None);
                        if (items != null && items.Count() > 0)
                        {
                            foreach (String resp in items)
                            {
                                if (resp != "[{" && resp != "{")
                                {
                                    GithubJsonItem gjson = new GithubJsonItem(name + resp);
                                    rtn.Add(gjson);
                                }
                            }
                        }
                        ghrs.Close();
                        ghrs = null;
                    }
                }
                ghr.Close();
                ghr = null;
            }
            return(rtn);
        }
Example #2
0
        /// <summary>
        /// Performs a Get WebRequest to the specified URL and returns a collection of GithubJsonItems.
        /// </summary>
        /// <param name="uri">The url for the Get Request.</param>
        /// <returns></returns>
        private Collection <GithubJsonItem> Get(String uri)
        {
            Collection <GithubJsonItem> rtn = new Collection <GithubJsonItem>();

            var request = (HttpWebRequest)WebRequest.Create(uri);

            request.UserAgent         = StringValue.psftitle;
            request.AllowAutoRedirect = true;

            WebResponse response = null;

            try
            {
                response = request.GetResponse();
            }
            catch (WebException wex)
            {
                _ratelimitremaining = GetRateLimitRemaining(wex.Response);
                _errors.Add(uri + ":" + wex.Message);
            }
            catch (Exception e)
            {
                _errors.Add(uri + ":" + e.Message);
            }
            if (response != null)
            {
                _ratelimitremaining = GetRateLimitRemaining(response);
                _lastmodified       = GetLastModified(response);

                if (response.ContentType == StringValue.ContentTypeJSON)
                {
                    var responseStream = response.GetResponseStream();
                    if (responseStream != null)
                    {
                        var responseReader = new StreamReader(responseStream);
                        var responseString = responseReader.ReadToEnd();
                        responseReader.Close();
                        responseReader = null;
                        var name  = "\"name\"";
                        var split = new string[] { "\"name\"" };
                        var items = responseString.Split(split, StringSplitOptions.None);
                        if (items != null && items.Count() > 0)
                        {
                            foreach (var resp in items)
                            {
                                if (resp != "[{" && resp != "{")
                                {
                                    GithubJsonItem gjson = new GithubJsonItem(name + resp);
                                    rtn.Add(gjson);
                                }
                            }
                        }
                        responseStream.Close();
                        responseStream = null;
                    }
                }
                response.Close();
                response = null;
            }
            return(rtn);
        }
 /// <summary>
 /// Performs a Get WebRequest to the specified URL and returns a collection of GithubJsonItems.
 /// </summary>
 /// <param name="uri">The url for the Get Request.</param>
 /// <returns></returns>
 private Collection<GithubJsonItem> Get(String uri)
 {
     Collection<GithubJsonItem> rtn = new Collection<GithubJsonItem>();
     ghc = (HttpWebRequest)WebRequest.Create(uri);
     ghc.UserAgent = StringValue.psftitle;
     ghc.AllowAutoRedirect = true;
     WebResponse ghr = null;
     try
     {
         ghr = ghc.GetResponse();
     }
     catch (WebException wex)
     {
         ratelimitremaining = GetRateLimitRemaining(wex.Response);
         errors.Add(uri + ":" + wex.Message);
     }
     catch (Exception e)
     {
         errors.Add(uri + ":" + e.Message);
     }
     if (ghr != null)
     {
         ratelimitremaining = GetRateLimitRemaining(ghr);
         lastmodified = GetLastModified(ghr);
         if (ghr.ContentType == StringValue.ContentTypeJSON)
         {
             Stream ghrs = ghr.GetResponseStream();
             if (ghrs != null)
             {
                 StreamReader ghrdr = new StreamReader(ghrs);
                 String response = ghrdr.ReadToEnd();
                 ghrdr.Close();
                 ghrdr = null;
                 String name = "\"name\"";
                 String[] split = new string[] { "\"name\"" };
                 String[] items = response.Split(split, StringSplitOptions.None);
                 if (items != null && items.Count() > 0)
                 {
                     foreach (String resp in items)
                     {
                         if (resp != "[{" && resp != "{")
                         {
                             GithubJsonItem gjson = new GithubJsonItem(name + resp);
                             rtn.Add(gjson);
                         }
                     }
                 }
                 ghrs.Close();
                 ghrs = null;
             }
         }
         ghr.Close();
         ghr = null;
     }
     return rtn;
 }