Esempio n. 1
0
        public static List <Ship> GetAllShipsFromWG()
        {
            List <Ship>  AllShips = new List <Ship>();
            ShipImporter Importer = WGAPI.GetShipData();

            if (Importer.Status.Equals("ok"))
            {
                int Pages = Importer.MetaInfo.Pages;
                foreach (KeyValuePair <string, Ship> ShipData in Importer.ShipData)
                {
                    AllShips.Add(ShipData.Value);
                }
                if (Pages > 1)
                {
                    for (int Counter = 2; Counter <= Pages; Counter++)
                    {
                        Importer = WGAPI.GetShipData(Counter);
                        if (Importer.Status.Equals("ok"))
                        {
                            foreach (KeyValuePair <string, Ship> ShipData in Importer.ShipData)
                            {
                                AllShips.Add(ShipData.Value);
                            }
                        }
                    }
                }
            }
            return(AllShips);
        }
Esempio n. 2
0
        public static ShipImporter GetShipData(int page)
        {
            try { Setup(); } catch (Exception) { }
            string path           = $"encyclopedia/ships/?application_id={APP_ID}&page_no={page}";
            string responseString = "";
            var    response       = Client.GetAsync(path).Result;

            if (response.IsSuccessStatusCode)
            {
                var responseContent = response.Content;
                responseString = responseContent.ReadAsStringAsync().Result;
            }
            ShipImporter ImportedShips = JsonConvert.DeserializeObject <ShipImporter>(responseString);

            return(ImportedShips);
        }