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 CharWin() { InitializeComponent(); ACCESS_TOKEN = GetToken().Result; 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); } AllClasses = ClassData.getAllWoWClasses(ACCESS_TOKEN); if (AllClasses == null) { return; } }