Beispiel #1
0
        private static void ParseBanners()
        {
            if (VersionCheck.BannersUrl == null)
            {
                Debug.Print("Error: BannersUrl is null in ParseBanners");
            }

            try
            {
                //Grab the string from the RenX Website.
                string jsonText = new WebClient().DownloadString(VersionCheck.BannersUrl);

                //Turn it into a JSon object that we can parse.
                var results = JsonConvert.DeserializeObject <dynamic>(jsonText);

                foreach (var data in results)
                {
                    BannerInfo info = new BannerInfo
                    {
                        MWebsiteLink = data["Link"],
                    };

                    string bannerUrl = data["Banner"];
                    info.MBannerImageSource = DownloadImage(bannerUrl);

                    string   ipString = data["IP"] ?? "-1";
                    string[] ips      = ipString.Split(RenXWebLinks.RenxServerSettingSpaceSymbol);

                    foreach (string ip in ips)
                    {
                        /*
                         * AX: No longer are we ripping the port off of the IP Address here for banners,
                         *  Reason: Game server providers use the same server IP Address for multiple instances of the same game, this fixes banners for these server types.
                         */

                        _banners.Add(ip, info);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.Print(ex.Message);
                // Swallow any exceptions (usually connectivity or parse errors).
            }
        }
Beispiel #2
0
        private static void ParseBanners()
        {
            try
            {
                //Grab the string from the RenX Website.
                string jsonText = new WebClient().DownloadString(RenXWebLinks.RENX_BANNERS_JSON_URL);

                //Turn it into a JSon object that we can parse.
                var results = JsonConvert.DeserializeObject <dynamic>(jsonText);

                foreach (var Data in results)
                {
                    BannerInfo info = new BannerInfo
                    {
                        m_WebsiteLink = Data["Link"],
                    };

                    string bannerURL = Data["Banner"];
                    info.m_BannerImageSource = DownloadImage(bannerURL);

                    string   ipString = Data["IP"] ?? "-1";
                    string[] ips      = ipString.Split(RenXWebLinks.RENX_SERVER_SETTING_SPACE_SYMBOL);

                    foreach (string ip in ips)
                    {
                        /*
                         * AX: No longer are we ripping the port off of the IP Address here for banners,
                         *  Reason: Game server providers use the same server IP Address for multiple instances of the same game, this fixes banners for these server types.
                         */

                        Banners.Add(ip, info);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.Print(ex.Message);
                // Swallow any exceptions (usually connectivity or parse errors).
            }
        }