Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        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);
        }