Esempio n. 1
0
        public UpdateManifest DownloadManifest()
        {
            var dataString = string.Empty;

            try
            {
                dataString = GetUpdateManifestData(updateDataUrl);
            }
            catch (Exception e)
            {
                logger.Warn(e, "Failed to download update manifest from main URL");
            }

            try
            {
                if (string.IsNullOrEmpty(dataString) && !string.IsNullOrEmpty(updateDataUrl2))
                {
                    dataString = GetUpdateManifestData(updateDataUrl2);
                }
            }
            catch (Exception e)
            {
                logger.Warn(e, "Failed to download update manifest from secondary URL");
            }

            if (string.IsNullOrEmpty(dataString))
            {
                throw new Exception("Failed to download update manifest.");
            }

            updateManifest = JsonConvert.DeserializeObject <UpdateManifest>(dataString);
            return(updateManifest);
        }
Esempio n. 2
0
        public UpdateManifest.Package GetUpdatePackage(UpdateManifest manifest, Version currentVersion)
        {
            var diff = manifest.Packages.FirstOrDefault(a => a.BaseVersion.ToString(2) == currentVersion.ToString(2));

            if (diff != null)
            {
                return(diff);
            }

            return(manifest.Packages.First(a => a.BaseVersion == manifest.LatestVersion));
        }