Ejemplo n.º 1
0
        /// <remarks>
        /// Calling this method invokes ONE page load and ONE parse operations
        /// </remarks>
        public async Task <List <ShipSummary> > GetShipList()
        {
            var html = await GetPageHtml("List_of_Ships");

            var result = html.ExtractFromHtml("shipList");

            if (result?["ships"] == null)
            {
                throw new HtmlParseException("Errors encountered while parsing initial search results!");
            }
            var ships = new List <ShipSummary>();

            foreach (var ship in result["ships"].Where(s => s.Count() != 0))
            {
                var id      = ship["id"].ToString();
                var summary = new ShipSummary {
                    Id     = id,
                    Name   = ship["name"].ToString(),
                    Rarity = ParseRarity(ship["rarity"].ToString()).ToString(),
                    Type   = IsRetrofit(id) ? (ship["subtype"]?.ToString() ?? ship["type"].ToString()) : ship["type"].ToString(),
                    // Subtype = ship["subtype"].ToString(),
                    FactionName = ship["faction"].ToString()
                };
                ships.Add(summary);
            }
            return(ships);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Gets the details of a given ship.
 /// </summary>
 /// <remarks>
 /// This will *not* validate that a ship name is correct first!
 /// Always use a result from <see cref="WikiSearcher.GetShipList"/> to get details.
 /// Calling this method invokes ONE page load and TWO parse operations.
 /// </remarks>
 /// <param name="summary">A ship <see cref="Azurite.ShipSummary"/> to get details for.</param>
 /// <returns>A Task for the details of the requested ship.</returns>
 public async Task <Ship> GetShipDetails(ShipSummary summary)
 {
     if (string.IsNullOrWhiteSpace(summary.Name))
     {
         var ship = (await GetShipList()).FirstOrDefault(s => s.Id.Equals(summary.Id, StringComparison.InvariantCultureIgnoreCase));
         return(await GetShipDetails(ship));
     }
     return(await GetShipDetails(summary.Name, summary.Id, ParseRarity(summary.Rarity)));
 }
Ejemplo n.º 3
0
 public Task <Ship> GetShipDetails(ShipSummary summary)
 {
     return(Task.FromResult(_client.GetShipCollection().FindById(summary.Id)));
 }
Ejemplo n.º 4
0
 public Task <Ship> GetShipDetails(ShipSummary summary)
 {
     throw new System.NotImplementedException();
 }