Example #1
0
        /// <summary>
        /// Checks if the application is up-to-date
        /// </summary>
        /// <returns>Returns true if up to date, false if not</returns>
        public bool ApplicationUpToDate()
        {
            /*Download release tags from github api*/
            /*If API changes this will break, so for future visitors - this might be your problem*/
            string refJson = DownloadString("https://api.github.com/repos/Ezzpify/SteamAuthenticator/git/refs/tags");

            Config.Github gitHub = null;
            if (refJson.Length > 0)
            {
                try
                {
                    /*Parse github response - get last release in json array*/
                    gitHub = JsonConvert.DeserializeObject <Config.Github[]>(refJson).Last();

                    /*Get versions*/
                    string gitLatestVersion  = [email protected]([email protected]('/') + 1);
                    string appCurrentVersion = Application.ProductVersion;

                    /*Check if version string from github is in the wrong format (not ie 1.5.5)*/
                    /*If it's not then something is broken or changed at github, but instead of bugging user we'll return true*/
                    if (!new Regex(@"^[0-9.]+$").IsMatch(gitLatestVersion))
                    {
                        return(true);
                    }

                    /*If version are the same*/
                    if (gitLatestVersion == appCurrentVersion)
                    {
                        return(true);
                    }
                }
                catch
                {
                    /*API response probably changed*/
                    /*But we want the application to be usable, so return true to not bug user*/
                    return(true);
                }
            }

            /*There's an update available, set update variable class and return false*/
            string commitJson = DownloadString([email protected]);

            update = JsonConvert.DeserializeObject <Config.GithubRelease>(commitJson);
            return(false);
        }
Example #2
0
        /// <summary>
        /// Checks if the application is up-to-date
        /// </summary>
        /// <returns>Returns true if up to date, false if not</returns>
        public bool ApplicationUpToDate()
        {
            /*Download release tags from github api*/
            /*If API changes this will break, so for future visitors - this might be your problem*/
            string refJson = DownloadString("https://api.github.com/repos/Ezzpify/SteamAuthenticator/git/refs/tags");
            Config.Github gitHub = null;
            if (refJson.Length > 0)
            {
                try
                {
                    /*Parse github response - get last release in json array*/
                    gitHub = JsonConvert.DeserializeObject<Config.Github[]>(refJson).Last();

                    /*Get versions*/
                    string gitLatestVersion = [email protected]([email protected]('/') + 1);
                    string appCurrentVersion = Application.ProductVersion;

                    /*Check if version string from github is in the wrong format (not ie 1.5.5)*/
                    /*If it's not then something is broken or changed at github, but instead of bugging user we'll return true*/
                    if (!new Regex(@"^[0-9.]+$").IsMatch(gitLatestVersion)) return true;

                    /*If version are the same*/
                    if (gitLatestVersion == appCurrentVersion) return true;
                }
                catch
                {
                    /*API response probably changed*/
                    /*But we want the application to be usable, so return true to not bug user*/
                    return true;
                }
            }

            /*There's an update available, set update variable class and return false*/
            string commitJson = DownloadString([email protected]);
            update = JsonConvert.DeserializeObject<Config.GithubRelease>(commitJson);
            return false;
        }