public List<Player> GetPlayersFromRoster(HtmlDocument rosterPage, Team team) { List<Player> players = new List<Player>(); HtmlNode table = FindRosterTable(rosterPage.DocumentNode); foreach (HtmlNode row in table.Descendants("tr").Skip(2)) { IEnumerable<HtmlNode> cells = row.Descendants("td"); string name = cells.ElementAt(1).Descendants("a").First().InnerText.Trim(); PlayerBio bio = new PlayerBio( GetHeight(cells.ElementAt(3).InnerText), GetWeight(cells.ElementAt(4).InnerText), GetYearsPro(cells.ElementAt(7).InnerText), GetBirthDate(cells.ElementAt(5).InnerText), Notations.RUS ); PlayerRoster roster = new PlayerRoster( GetPos(cells.ElementAt(2).InnerText), GetNumber(cells.ElementAt(0).InnerText) ); Player player = new Player(name, bio, roster, team); player.College = new College(cells.ElementAt(6).InnerText.Replace(" ", string.Empty). Replace(";", string.Empty).Trim()); player.Href = cells.ElementAt(1).Descendants("a").First().GetAttributeValue("href", "#"); players.Add(player); } return players; }
public Player(string name, PlayerBio bio, PlayerRoster roster, Team team) { this.name = name; this.bio = bio; this.roster = roster; this.team = team; }
public Team GetTeamInfo(HtmlNode div) { HtmlNode[] links = div.Descendants("a").ToArray(); string name = div.Descendants("h1").First().InnerHtml; name = name.Substring(name.IndexOf(" ") + 1, name.IndexOf("Roster") - 9); string divName = links[3].NextSibling.InnerHtml; divName = divName.Substring(1, divName.Length - 12); Team team = new Team(name, new Division(divName)); string coachName = links[5].InnerHtml; team.Coach = new Coach(coachName, team); HtmlNode[] strongs = div.Descendants("strong").ToArray(); string arenaName = strongs[strongs.Length - 2].NextSibling.InnerHtml; arenaName = arenaName.Substring(1, arenaName.IndexOf("&") - 2); string arenaAttendance = strongs[strongs.Length - 1].NextSibling.InnerHtml; arenaAttendance = arenaAttendance.Substring(1, arenaAttendance.IndexOf("(") - 2).Replace(",", string.Empty); team.Arena = new Arena(arenaName, int.Parse(arenaAttendance)); return team; }
public Game(Team homeTeam, Team visitorTeam, DateTime date, List<GamePeriod> periods) : this(homeTeam, visitorTeam, date) { this.periods = periods; }
public Game(Team homeTeam, Team visitorTeam, DateTime date) { this.homeTeam = homeTeam; this.visitorTeam = visitorTeam; this.date = date; }
public Coach(string name, Team team) { this.name = name; this.team = team; }