public async Task <AssemblyInfoModel> GetOnlineAssemblies() { try { using (HttpClient client = new HttpClient()) { Uri addr = new Uri("https://winconfig.azurewebsites.net/apipeek/config.json"); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, addr); HttpResponseMessage response = await client.SendRequestAsync(request); if (!response.IsSuccessStatusCode) { return(null); } string result = await response.Content.ReadAsStringAsync(); AssemblyInfoModel model = JsonConvert.DeserializeObject <AssemblyInfoModel>(result); return(model.IsValid() ? model : null); } } catch (Exception ex) { Debug.WriteLine($"Error loading online config.json: {ex}"); return(null); } }
public async Task <Assembly[]> GetAssembliesAsync() { AssemblyInfoModel assemblyModel = await GetOnlineAssemblies(); if (assemblyModel == null) { return(new Assembly[0]); } Assembly[] assemblies = assemblyModel.Assemblies.Select(GetAssembly).ToArray(); return(assemblies); }