private Catalog GetCatalogDataFromAPI(ECatalogTypes type) { try { var catalog = new Catalog(); var requisicaoWeb = WebRequest.CreateHttp("https://api.scryfall.com/catalog/" + new EnumReturns().ToString(type)); requisicaoWeb.Method = "GET"; requisicaoWeb.UserAgent = "RequisicaoWebDemo"; using (var resposta = requisicaoWeb.GetResponse()) { var streamDados = resposta.GetResponseStream(); StreamReader reader = new StreamReader(streamDados); object objResponse = reader.ReadToEnd(); catalog = JsonConvert.DeserializeObject <Catalog>(objResponse.ToString()); streamDados.Close(); resposta.Close(); } return(catalog); } catch (Exception ex) { MessageBox.Show("Wrong request ! " + ex.Message, "Error"); return(new Catalog()); } }
private void LoadComboboxWithCatalog(ComboBox cbo, ECatalogTypes catalogType) { KeyValuePair <ECatalogTypes, Catalog> catalog = Main.Catalogs.Where(c => c.Key == catalogType).FirstOrDefault(); foreach (String data in catalog.Value.Data) { cbo.Items.Add(data); } }
public String ToString(ECatalogTypes type) { if (type == ECatalogTypes.CardNames) { return("card-names"); } else if (type == ECatalogTypes.ArtistNames) { return("artist-names"); } else if (type == ECatalogTypes.WordBank) { return("word-bank"); } else if (type == ECatalogTypes.CreatureTypes) { return("creature-types"); } else if (type == ECatalogTypes.PlaneswalkerTypes) { return("planeswalker-types"); } else if (type == ECatalogTypes.LandTypes) { return("land-types"); } else if (type == ECatalogTypes.ArtifactTypes) { return("artifact-types"); } else if (type == ECatalogTypes.EnchantmentYypes) { return("enchantment-types"); } else if (type == ECatalogTypes.SpellTypes) { return("spell-types"); } else if (type == ECatalogTypes.Powers) { return("powers"); } else if (type == ECatalogTypes.Toughnesses) { return("toughnesses"); } else if (type == ECatalogTypes.Loyalties) { return("loyalties"); } else if (type == ECatalogTypes.Watermarks) { return("watermarks"); } else if (type == ECatalogTypes.KeywordAbilities) { return("keyword-abilities"); } else if (type == ECatalogTypes.KeywordActions) { return("keyword-actions"); } else if (type == ECatalogTypes.AbilityWords) { return("ability-words"); } else { return(String.Empty); } }