public bool CheckForUpdates()
 {
     // If we aren't pending a check, don't check anything...
     if (state != State.PENDING)
     {
         return(false);
     }
     SetState(State.CHECKING);
     try
     {
         WebClient fetcher = (new WebClient());
         fetcher.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2;)");
         var APIResponse = fetcher.DownloadString("https://api.github.com/repos/MarshallOfSound/Google-Play-Music-Desktop-Player-UNOFFICIAL-/releases");
         List <GithubRelease> releaseList   = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize <List <GithubRelease> >(APIResponse);
         GithubRelease        latestRelease = this.SelectLatestRelease(releaseList, Properties.Settings.Default.BetaStream);
         this.update = latestRelease;
         bool isBetter = new Version(latestRelease.tag_name) > new Version(CoreMusicApp.CURRENT_VERSION);
         if (!isBetter)
         {
             SetState(State.PENDING);
         }
         return(isBetter);
     }
     catch (Exception e)
     {
         // Something went wrong while fetching from the GitHub API
         SetState(State.PENDING);
         return(false);
     }
 }
        private GithubRelease SelectLatestRelease(List <GithubRelease> releaseList, bool isBeta)
        {
            Version       minimumVersion = new Version(0, 0, 0);
            GithubRelease latestRelease  = releaseList[0];

            releaseList.ForEach((release) =>
            {
                Version tmpVersion = new Version(release.tag_name);
                if (minimumVersion < tmpVersion)
                {
                    if (release.prerelease == isBeta || isBeta)
                    {
                        minimumVersion = tmpVersion;
                        latestRelease  = release;
                    }
                }
            });
            return(latestRelease);
        }
 public bool CheckForUpdates()
 {
     // If we aren't pending a check, don't check anything...
     if (state != State.PENDING)
     {
         return false;
     }
     SetState(State.CHECKING);
     try
     {
         WebClient fetcher = (new WebClient());
         fetcher.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2;)");
         var APIResponse = fetcher.DownloadString("https://api.github.com/repos/MarshallOfSound/Google-Play-Music-Desktop-Player-UNOFFICIAL-/releases");
         List<GithubRelease> releaseList = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize<List<GithubRelease>>(APIResponse);
         GithubRelease latestRelease = this.SelectLatestRelease(releaseList, Properties.Settings.Default.BetaStream);
         this.update = latestRelease;
         bool isBetter = new Version(latestRelease.tag_name) > new Version(CoreMusicApp.CURRENT_VERSION);
         if (!isBetter) {
             SetState(State.PENDING);
         }
         return isBetter;
     }
     catch (Exception e)
     {
         // Something went wrong while fetching from the GitHub API
         SetState(State.PENDING);
         return false;
     }
 }