コード例 #1
0
        private static void ExtractTeamFromSection(Season season, TeamSection teamSection)
        {
            string acronym = teamSection.TeamInformationNode.Attributes["class"].Value.Replace("TeamScoringPro_", "");
            string name    = teamSection.TeamInformationNode.FirstChild.Id.SplitCamelCase().Trim();

            if (name.Length < 2)
            {
                name = teamSection.TeamInformationNode.FirstChild.GetAttributeValue("name", "ERROR").SplitCamelCase();
            }
            name = name.Replace(".", "");

            Team team = new Team()
            {
                Name    = name,
                Acronym = acronym,
                Skaters = new List <Skater>(),
                Goalies = new List <Goalie>(),
            };

            ExtractSkatersFromSection(team, teamSection);
            ExtractGoaliesFromSection(team, teamSection);

            RemoveFakePlayers(team);
            RemoveTradedSeasonsForFreeAgents(team);
            RemoveSkatersWhoDontPlay(team);

            season.Teams.Add(team);
        }
コード例 #2
0
        private static void ExtractGoaliesFromSection(Team team, TeamSection teamSection)
        {
            // Goalie Stat Section
            foreach (HtmlNode row in teamSection.GoalieInformationNode.Descendants("tr").Where(a => a.ParentNode.Name != "thead"))
            {
                IList <HtmlNode> cells = row.Descendants("td").ToList();

                string name     = cells.First().InnerText;
                bool   isTraded = name.StartsWith("_");
                name = name.Replace("_", "").Trim();
                IEnumerable <string> acronyms = name.GetAcronymns();

                Goalie goalie = new Goalie()
                {
                    Name        = name.RemoveAcronyms(),
                    IsRookie    = acronyms.Contains("R"),
                    IsCaptain   = acronyms.Contains("C"),
                    IsAlternate = acronyms.Contains("A"),
                };

                ConvertCellsToStats(cells, goalie);

                if (isTraded)
                {
                    goalie.SeasonTotals.TeamAcronym = acronyms.Where(a => a.Length == 3).First();
                }

                team.Goalies.Add(goalie);
            }

            CombineTradedGoalieSubtotals(team);
        }
コード例 #3
0
        private static void ExtractSkatersFromSection(Team team, TeamSection teamSection)
        {
            // First Skater Stat Section
            foreach (HtmlNode row in teamSection.SkaterInformationNode1.Descendants("tr").Where(a => a.ParentNode.Name != "thead"))
            {
                IList <HtmlNode> cells = row.Descendants("td").ToList();

                string name     = cells.First().InnerText;
                bool   isTraded = name.StartsWith("_");
                name = name.Replace("_", "").Trim();
                IEnumerable <string> acronyms = name.GetAcronymns();

                Skater skater = new Skater()
                {
                    Name        = name.RemoveAcronyms(),
                    IsRookie    = acronyms.Contains("R"),
                    IsCaptain   = acronyms.Contains("C"),
                    IsAlternate = acronyms.Contains("A"),
                };

                ConvertCellsToStats(cells, skater);

                if (isTraded)
                {
                    skater.SeasonTotals.TeamAcronym = acronyms.Where(a => a.Length == 3).First();
                }

                team.Skaters.Add(skater);
            }

            // Second Skater Stat Section
            foreach (HtmlNode row in teamSection.SkaterInformationNode2.Descendants("tr").Where(a => a.ParentNode.Name != "thead"))
            {
                IList <HtmlNode>     cells    = row.Descendants("td").ToList();
                string               name     = cells.First().InnerText.Replace("_", "").Trim();
                IEnumerable <string> acronyms = name.GetAcronymns();

                Skater skater = new Skater()
                {
                    Name = name.RemoveAcronyms(),
                };

                FillInBlankColumnsWithZeros(cells);
                ConvertCellsToStats(cells, skater);
                team.Skaters.Add(skater);
            }

            CombineSplitSkaterStats(team);
            CombineTradedSkaterSubtotals(team);
        }