static public Tuple <List <string>, List <string> > GetAllReleases() { AdoptiumAPI_AvailableReleases all_releases = GetAvailableReleases(); List <string> releases = all_releases.Releases; List <string> LTS_releases = all_releases.LTSReleases; return(new Tuple <List <string>, List <string> >(releases, LTS_releases)); }
static public AdoptiumAPI_AvailableReleases GetAvailableReleases() { const string URL = baseURL + "info/available_releases"; List <string> releases = new List <string>(); List <string> LTS_releases = new List <string>(); string MostRecentFeatureRelease = ""; string MostRecentLTSRelease = ""; try { IWebProxy defaultWebProxy = WebRequest.DefaultWebProxy; defaultWebProxy.Credentials = CredentialCache.DefaultCredentials; HttpClientHandler hch = new HttpClientHandler(); hch.Proxy = defaultWebProxy; //hch.Proxy = ProxyConfigurator.GetWebProxy; //hch.UseProxy = ProxyConfigurator.UseProxy; var httpClient = new HttpClient(hch); httpClient.DefaultRequestHeaders.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json")); var response = httpClient.GetStringAsync(new Uri(URL)).Result; JObject joResponse = JObject.Parse(response); JArray array = (JArray)joResponse["available_releases"]; foreach (var a in array) { releases.Add(a.Value <string>()); } JArray arrayLTS = (JArray)joResponse["available_lts_releases"]; foreach (var a in arrayLTS) { LTS_releases.Add(a.Value <string>()); } MostRecentFeatureRelease = (string)joResponse["most_recent_feature_release"]; MostRecentLTSRelease = (string)joResponse["most_recent_lts"]; } catch (Exception ex) { var ie = ex; while (ie.InnerException != null) { ie = ie.InnerException; } var error_message = $"GetAvailableReleases[{URL}]: {ex.Message} => {ie.Message}"; MessageBox.Show( $"Unable to get list of {Branding.TargetProduct} releases. Make sure you are connected to the internet and {baseDOMAIN} is online." + Environment.NewLine + Environment.NewLine + Environment.NewLine + $"Tech details:{Environment.NewLine}{error_message}" , $"{Branding.TargetProduct} API Error", MessageBoxButton.OK, MessageBoxImage.Error); } AdoptiumAPI_AvailableReleases info = new AdoptiumAPI_AvailableReleases(); info.Releases = releases; info.LTSReleases = LTS_releases; info.MostRecentFeatureRelease = MostRecentFeatureRelease; info.MostRecentLTSRelease = MostRecentLTSRelease; return(info); }