public static RealmStatus getAllRealms(string accessToken) { RealmStatus realmList = null; string address = @"https://us.api.blizzard.com/wow/realm/status?locale=en_US&access_token=" + accessToken; WebRequest request = WebRequest.Create(address); try { Cursor.Current = Cursors.WaitCursor; HttpWebResponse httpResponse = (HttpWebResponse)request.GetResponse(); Stream responseStream = httpResponse.GetResponseStream(); if (responseStream != null) { using (StreamReader sr = new StreamReader(responseStream)) { string responseJSon = sr.ReadToEnd(); realmList = JsonConvert.DeserializeObject <RealmStatus>(responseJSon); } } } catch (WebException) { MessageBox.Show("Unable to get list of realms."); } finally { Cursor.Current = Cursors.Default; } return(realmList); }
public MountWin() { DataTable GridTable; InitializeComponent(); dataGridView1.DataSource = new DataTable(); GridTable = (DataTable)dataGridView1.DataSource; GridTable.Columns.Add("Name", typeof(string)); GridTable.Columns.Add("Ground", typeof(bool)); GridTable.Columns.Add("Flying", typeof(bool)); GridTable.Columns.Add("Aquatic", typeof(bool)); GridTable.Columns.Add("Jumping", typeof(bool)); // get the access token ACCESS_TOKEN = GetToken().Result; // Get the list of all the mounts in the system if it hasn't been done yet AllMounts = WoWMounts.getAllMounts(ACCESS_TOKEN); if (AllMounts == null) { return; } AllMounts.mounts.Sort((x, y) => String.Compare(x.name, y.name)); AllRealms = RealmStatus.getAllRealms(ACCESS_TOKEN); if (AllRealms == null) { return; } AllRealms.realms.Sort((x, y) => String.Compare(x.name, y.name)); foreach (Realm realm in AllRealms.realms) { ServerComboBox.Items.Add(realm.name); } return; }