public async Task <UpdateMeta> CheckForUpdate()
        {
            var url = BuildUrl("spec.xml");

            var response = await _httpClient.GetStringAsync(url);

            var tempPath = Path.GetTempPath();

            var updateFilePath = Path.Combine(tempPath, Guid.NewGuid() + ".xml");

            // To be able to deserialize XML, we need a "temporary" file
            // so save the response to disk, deserialize and then
            // delete the file from the user's machine
            File.WriteAllText(updateFilePath, response);

            var deserialized = SpecificationParser.Deserialize(updateFilePath);

            File.Delete(updateFilePath);

            var currentVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();

            var currentParsedVersion = new Version(currentVersion);
            var remoteParsedVersion  = new Version(deserialized.ProductVersion);

            var isUpdateAvailable = remoteParsedVersion > currentParsedVersion;

            return(new UpdateMeta(isUpdateAvailable, deserialized.ProductVersion));
        }
Esempio n. 2
0
        private static Specification GetSpecification(string specificationPath)
        {
            if (!File.Exists(specificationPath))
            {
                throw new InvalidOperationException("Cannot compose WXS with missing NETWeasel Spec file, ensure spec.xml exists");
            }

            return(SpecificationParser.Deserialize(specificationPath));
        }