Exemplo n.º 1
0
        private static void CheckForUpdates(out PdnVersionManifest manifestResult, out int latestVersionIndexResult, out Exception exception)
        {
            exception = null;
            PdnVersionManifest updatesManifest = null;

            manifestResult           = null;
            latestVersionIndexResult = -1;
            int num = 2;

            while (num > 0)
            {
                try
                {
                    updatesManifest = GetUpdatesManifest(out exception);
                    num             = 0;
                    continue;
                }
                catch (Exception exception2)
                {
                    exception = exception2;
                    num--;
                    if (num == 0)
                    {
                        updatesManifest = null;
                    }
                    continue;
                }
            }
            if (updatesManifest != null)
            {
                int  latestStableVersionIndex = updatesManifest.GetLatestStableVersionIndex();
                int  latestBetaVersionIndex   = updatesManifest.GetLatestBetaVersionIndex();
                bool flag2 = AppSettings.Instance.Updates.AutoCheckForPrerelease.Value || PdnInfo.IsPrereleaseBuild;
                int  index = latestStableVersionIndex;
                if ((flag2 && (latestBetaVersionIndex != -1)) && ((latestStableVersionIndex == -1) || (updatesManifest.VersionInfos[latestBetaVersionIndex].Version >= updatesManifest.VersionInfos[latestStableVersionIndex].Version)))
                {
                    index = latestBetaVersionIndex;
                }
                if ((index != -1) && (PdnInfo.IsTestMode || (updatesManifest.VersionInfos[index].Version > PdnInfo.Version)))
                {
                    manifestResult           = updatesManifest;
                    latestVersionIndexResult = index;
                }
            }
        }
Exemplo n.º 2
0
        private static void CheckForUpdates(
            out PdnVersionManifest manifestResult,
            out int latestVersionIndexResult,
            out Exception exception)
        {
            exception = null;
            PdnVersionManifest manifest = null;

            manifestResult           = null;
            latestVersionIndexResult = -1;

            int retries = 2;

            while (retries > 0)
            {
                try
                {
                    manifest = GetUpdatesManifest(out exception);
                    retries  = 0;
                }

                catch (Exception ex)
                {
                    exception = ex;
                    --retries;

                    if (retries == 0)
                    {
                        manifest = null;
                    }
                }
            }

            if (manifest != null)
            {
                int stableIndex = manifest.GetLatestStableVersionIndex();
                int betaIndex   = manifest.GetLatestBetaVersionIndex();

                // Check for betas as well?
                bool checkForBetas = ("1" == Settings.SystemWide.GetString(PdnSettings.AlsoCheckForBetas, "0"));

                // Figure out which version we want to compare against the current version
                int latestIndex = stableIndex;

                if (checkForBetas)
                {
                    // If they like betas, and if the beta is newer than the latest stable release,
                    // then offer it to them.
                    if (betaIndex != -1 &&
                        (stableIndex == -1 || manifest.VersionInfos[betaIndex].Version >= manifest.VersionInfos[stableIndex].Version))
                    {
                        latestIndex = betaIndex;
                    }
                }

                // Now compare that version against the current version
                if (latestIndex != -1)
                {
                    if (PdnInfo.IsTestMode ||
                        manifest.VersionInfos[latestIndex].Version > PdnInfo.GetVersion())
                    {
                        manifestResult           = manifest;
                        latestVersionIndexResult = latestIndex;
                    }
                }
            }
        }