예제 #1
0
        private bool readRepository(string url)
        {
            System.Net.ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true;            // or you get an exeption, because mono doesnt trust anyone
            //normalize it

            if (!url.StartsWith("https://raw.github.com/"))
            {
                Uri urlNorm = new Uri(url);
                url = urlNorm.Host;
            }
            String repoinfo = null;

            try {
                WebClientTimeOut client = new WebClientTimeOut();
                if (url.StartsWith("https://raw.github.com/"))
                {
                    repoinfo = client.DownloadString(new Uri(url + "/repoinfo.txt"));
                }
                else
                {
                    repoinfo = client.DownloadString(new Uri("http://" + url + "/repoinfo"));
                }
            } catch (WebException ex) {
                Console.WriteLine(ex);
                return(false);
            }

            RepoInfoMessage message = null;

            try {
                JsonReader reader = new JsonReader();
                message = reader.Read(repoinfo, typeof(RepoInfoMessage)) as RepoInfoMessage;
            } catch {
                return(false);
            }

            if (message == null)
            {
                return(false);
            }

            if (!message.msg.Equals("success"))
            {
                return(false);
            }

            Repo repo = message.data;

            repo.tryToGetFavicon();
            repositories.Add(repo);

            return(this.tryToFetchModList(repo));
        }
예제 #2
0
        private bool readRepository(string url)
        {
            //normalize it
            Uri urlNorm = new Uri(url);

            url = urlNorm.Host;

            String repoinfo = null;

            try {
                WebClientTimeOut client = new WebClientTimeOut();
                repoinfo = client.DownloadString(new Uri("http://" + url + "/repoinfo"));
            } catch (WebException ex) {
                Console.WriteLine(ex);
                return(false);
            }

            RepoInfoMessage message = null;

            try {
                JsonReader reader = new JsonReader();
                message = reader.Read(repoinfo, typeof(RepoInfoMessage)) as RepoInfoMessage;
            } catch {
                return(false);
            }

            if (message == null)
            {
                return(false);
            }

            if (!message.msg.Equals("success"))
            {
                return(false);
            }

            Repo repo = message.data;

            repo.tryToGetFavicon();
            repositories.Add(repo);

            return(this.tryToFetchModList(repo));
        }