Ejemplo n.º 1
0
 protected void ReportElems(IGraphScene <IVisual, IVisualEdge> scene, IEnumerable <IVisual> elms, ILocator <IVisual> locator, AlignerOptions options)
 {
     elms
     .OrderBy(e => locator.GetLocation(e), new PointComparer {
         Delta = options.Distance.Width, Order = options.PointOrder
     })
     .ForEach(e => ReportDetail("\t{3}{0}\t{1}\t{2}", e.Data, locator.GetLocation(e), locator.GetSize(e), scene.Focused == e ? "*" : ""));
 }
Ejemplo n.º 2
0
        public async Task <IEnumerable <Country> > GetData()
        {
            var covid19Config = new Covid19ApiConfig();

            _configuration.GetSection("Covid19ApiConfig").Bind(covid19Config);
            // Use list of "countries" because DataModel contains a list of countries
            List <Country> countries = new List <Country>();

            using (HttpClient httpClient = new HttpClient())
            {
                var responseString = await httpClient.GetStringAsync($"{covid19Config.BaseUrl}{covid19Config.RequestUrl}");

                // Deserialize the Data Model
                countries = JsonConvert.DeserializeObject <Covid19ApiDataModel>(responseString).Countries;
            }

            countries.ForEach(async(country) =>
            {
                var location     = _locator.GetLocation(country.CountryCode);
                country.Location = location == null ? new LocationDataModel()
                {
                    Latitude = 0, Longitude = 0
                } : location;
            });

            //sorts countries in back end
            countries.Sort((pair1, pair2) => pair2.TotalConfirmed.CompareTo(pair1.TotalConfirmed));

            return(countries);
        }