/// <summary> /// Initialize the Object /// </summary> /// <param name="json">JSON representation of release</param> public CkanUpdate(string json) { dynamic response = JsonConvert.DeserializeObject(json); Version = new CkanModuleVersion( response.tag_name.ToString(), response.name.ToString() ); ReleaseNotes = ExtractReleaseNotes(response.body.ToString()); foreach (var asset in response.assets) { string url = asset.browser_download_url.ToString(); if (url.EndsWith("ckan.exe")) { ReleaseDownload = asset.browser_download_url; ReleaseSize = (long)asset.size; } else if (url.EndsWith("AutoUpdater.exe")) { UpdaterDownload = asset.browser_download_url; UpdaterSize = (long)asset.size; } } }
/// <summary> /// Fetches all the latest release info, populating our attributes in /// the process. /// </summary> public void FetchLatestReleaseInfo() { var response = MakeRequest(latestCKANReleaseApiUrl); try { // Check whether the release includes the auto updater foreach (var asset in response.assets) { string url = asset.browser_download_url.ToString(); if (url.EndsWith("ckan.exe")) { fetchedCkanUrl = new Tuple <Uri, long>(new Uri(url), (long)asset.size); } else if (url.EndsWith("AutoUpdater.exe")) { fetchedUpdaterUrl = new Tuple <Uri, long>(new Uri(url), (long)asset.size); } } if (fetchedUpdaterUrl == null) { // Older releases don't include the auto updater fetchedUpdaterUrl = RetrieveUrl(MakeRequest(oldLatestUpdaterReleaseApiUrl), 0); } } catch (Kraken) { LatestVersion = new ModuleVersion(Meta.GetVersion()); return; } ReleaseNotes = ExtractReleaseNotes(response.body.ToString()); LatestVersion = new CkanModuleVersion(response.tag_name.ToString(), response.name.ToString()); }