Ejemplo n.º 1
0
        public NewVersioInfo CheckNewAppVersionAvailable()
        {
            string url = settings.VersionCheck_VersionsUrl;

            var requestErrorPolicy = Policy <NewVersioInfo>
                                     .Handle <System.Net.WebException>()
                                     .Fallback(
                new NewVersioInfo()
            {
                IsAvailable = false
            }
                );

            IHTTPService httpService = (IHTTPService)trackerFactory.GetService <IHTTPService>();

            return(requestErrorPolicy.Execute(() =>
            {
                string versionJSON = httpService.SendGetRequest(url);
                JObject versions = JObject.Parse(versionJSON);
                SerializableVersion latest = new SerializableVersion(new Version(versions["Application"].ToString()));
                IApplicationService appService = (IApplicationService)trackerFactory.GetService <IApplicationService>();

                return new NewVersioInfo()
                {
                    IsAvailable = latest > appService.GetAssemblyVersion(),
                    Number = latest.ToString(),
                    DownloadUrl = GetLatestDownladUrl()
                };
            }));
        }
        public NewVersioInfo CheckNewAppVersionAvailable()
        {
            var requestErrorPolicy = Policy <NewVersioInfo>
                                     .Handle <System.Net.WebException>()
                                     .Fallback(new NewVersioInfo()
            {
                IsAvailable = false
            });

            string       url         = "https://raw.githubusercontent.com/MarioZG/elder-scrolls-legends-tracker/master/Build/versions.json";
            IHTTPService httpService = (IHTTPService)trackerFactory.GetService <IHTTPService>();

            return(requestErrorPolicy.Execute(() =>
            {
                string versionJSON = httpService.SendGetRequest(url);
                JObject versions = JObject.Parse(versionJSON);
                SerializableVersion latest = new SerializableVersion(new Version(versions["Application"].ToString()));
                IApplicationService appService = (IApplicationService)trackerFactory.GetService <IApplicationService>();

                return new NewVersioInfo()
                {
                    IsAvailable = latest > appService.GetAssemblyVersion(),
                    Number = latest.ToString(),
                    DownloadUrl = GetLatestDownladUrl()
                };
            }));
        }
        public void ToStringTest002()
        {
            SerializableVersion sv = new SerializableVersion(1, 2, 3, 4);

            Dictionary <string, string> testCases = new Dictionary <string, string>()
            {
                { "G", "1.2.3.4" },
                { "{M}.{m}.{b}.{r}", "1.2.3.4" },
                { "{M}.{m}", "1.2" },
                { "hello {M}.{m}", "hello 1.2" },
                { "mm", "1.2" },
                { "hello mm", "hello mm" }
            };

            foreach (KeyValuePair <string, string> textCase in testCases)
            {
                Assert.AreEqual(textCase.Value, sv.ToString(textCase.Key), "Failed for case {0}", textCase.Key);
            }
        }
        public void ToStringTest001()
        {
            SerializableVersion sv = new SerializableVersion(1, 2, 3, 4);

            Assert.AreEqual("1.2.3.4", sv.ToString());
        }