/// <summary>
        /// Searches for available updates on GitHub.
        /// </summary>
        /// <returns>Returns an update-search result.</returns>
        internal async Task <UpdateSearchResult> SearchForUpdateAsync(bool includePreReleases)
        {
            if (searchResult == null || !searchResult.UpdateAvailable)
            {
                var client        = new GitHubClient(new ProductHeaderValue("ModMyFactory"));
                var latestRelease = await client.GetLatestReleaseAsync("Artentus", "ModMyFactory", includePreReleases);

                var    version         = new ExtendedVersion(latestRelease.TagName);
                bool   updateAvailable = version > App.Version;
                string updateUrl       = latestRelease.HtmlUrl;
                searchResult = new UpdateSearchResult(updateAvailable, updateUrl, version);
            }

            return(searchResult);
        }
Esempio n. 2
0
        private string GetAssetName(ExtendedVersion version)
        {
            var sb = new StringBuilder();

            sb.Append("ModMyFactory_");
            sb.Append(version);

            #if PORTABLE
            sb.Append("_portable");
            #endif

            sb.Append(".zip");

            return(sb.ToString());
        }
Esempio n. 3
0
        /// <summary>
        /// Searches for available updates on GitHub.
        /// </summary>
        /// <returns>Returns an update-search result.</returns>
        internal async Task <UpdateSearchResult> SearchForUpdateAsync(bool includePreReleases)
        {
            if (searchResult == null || !searchResult.UpdateAvailable || (includePreReleases != this.includePreReleases))
            {
                this.includePreReleases = includePreReleases;

                var client        = new GitHubClient(new ProductHeaderValue("ModMyFactory"));
                var latestRelease = await client.GetLatestReleaseAsync("Artentus", "ModMyFactory", includePreReleases);

                var    version         = new ExtendedVersion(latestRelease.TagName);
                bool   updateAvailable = version > App.Version;
                string updateUrl       = latestRelease.HtmlUrl;

                string assetName = GetAssetName(version);
                string assetUrl  = latestRelease.Assets.FirstOrDefault(asset => asset.Name == assetName)?.BrowserDownloadUrl;

                searchResult = new UpdateSearchResult(updateAvailable, updateUrl, assetUrl, version);
            }

            return(searchResult);
        }