Last active
December 14, 2015 19:29
-
-
Save kumpera/5137002 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async Task ShowStuffAsync () | |
{ | |
var client = new HttpClient (); | |
var content = JsonValue.Parse (await client.GetStringAsync ("http://api.worldbank.org/countries?format=json")); | |
int number_of_countries = content [0] ["per_page"]; | |
int done = 0, error = 0; | |
CountriesLabel.Text = string.Format ("Countries: {0} done: 0 error: 0", number_of_countries); | |
foreach (JsonObject c in content [1]) { | |
try { | |
string country_url = string.Format ("http://api.worldbank.org/countries/{0}/indicators/NY.GDP.MKTP.CD&format=json", (string)c ["id"]); | |
var json = JsonValue.Parse (await client.GetStringAsync (country_url)); | |
var map = await LoadCountryLogoAsync (json ["name"]); | |
if (map != null){ | |
var position = await LookupCountryPositionAsync (c ["longitude"], c ["latitude"]); | |
if (position != null){ | |
AddPin (map, position); | |
status.Text = json ["name"]; | |
++done; | |
} | |
} | |
} catch (Exception e) { | |
++error; | |
status.Text = "Got exception "+ e; | |
} | |
CountriesLabel.Text = string.Format ("Countries: {0} done: {1} error: {2}", number_of_countries, done, error); | |
} | |
CountriesLabel.Text = string.Format ("Countries: {0}", number_of_countries); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
s/&/?/
http://api.worldbank.org/countries/{0}/indicators/NY.GDP.MKTP.CD?format=json