private async void TypeTextboxOne() { Type type; try { for (int i = 0; i < PokemonTypeList.Count; i++) { type = await pokeClient.GetResourceAsync <Type>(PokemonTypeList[i].TypeId); if (TypeOne == null) { for (int j = 0; j < type.Names.Count; j++) { if (type.Names[j].Language.Name == _language) { TypeThree = type.Names[j].Name; TypeThreeBgBrush = SetTypeColor(type); break; } } } } } catch { // } NotifyOfPropertyChange(() => IsTypeDeclared); NotifyOfPropertyChange(() => TypeThree); NotifyOfPropertyChange(() => TypeThreeBgBrush); PokemonTypeList.Clear(); }
protected void Page_Load(object sender, EventArgs e) { using (var webClient = new WebClient()) { // Representación STRING de nuestro JSON string rawJSON = webClient.DownloadString("https://pokeapi.co/api/v2/pokemon/"); //Convertir el JSON string a una lista de objetos PokemonTypeList pokemonTypeList = JsonConvert.DeserializeObject <PokemonTypeList>(rawJSON); Console.WriteLine(pokemonTypeList.Pokemon.Count); //this.pok = pokemonTypeList[0]; } }
private void LoadPokemonType(Pokemon pokemonInfo) { for (int i = 0; i < pokemonInfo.Types.Count; i++) { if (p > 0) { break; } PokemonTypeList.Add(new TypeModel { TypeUrl = pokemonInfo.Types[i].Type.Url, TypeId = Int32.Parse(pokemonInfo.Types[i].Type.Url.Where(Char.IsDigit).ToArray()) }); if (PokemonTypeList[i].TypeId < 30) { PokemonTypeList[i].TypeId -= 20; } else if (PokemonTypeList[i].TypeId < 999) { PokemonTypeList[i].TypeId -= 200; } else { PokemonTypeList[i].TypeId -= 2000; } } p = 1; switch (PokemonTypeList.Count) { case 1: TypeTextboxOne(); break; case 2: TypeTextboxTwo(); break; default: TypeTextboxThree(); break; } p = 0; }