예제 #1
0
 private static BowlingRecord CreateBowlingRecord(BowlerInnings innings)
 {
     return new BowlingRecord
                {
                    PlayerId = innings.BowlerId,
                    Team = innings.Team,
                    BallsBowled = innings.BallsBowled.HasValue ? innings.BallsBowled.Value : 0,
                    Maidens = innings.Maidens.HasValue ? innings.Maidens.Value : 0,
                    Runs = innings.Runs.HasValue ? innings.Runs.Value : 0,
                    Wickets = innings.Wickets.HasValue ? innings.Wickets.Value : 0,
                    NoBalls = innings.NoBalls.HasValue ? innings.NoBalls.Value : 0,
                    Wides = innings.Wides.HasValue ? innings.Wides.Value : 0
                };
 }
예제 #2
0
        private BowlerInnings ParseBowlerInnings(HtmlNode row)
        {
            HtmlNodeCollection cells = row.SelectNodes("./td");
            BowlerInnings innings = new BowlerInnings();

            HtmlNode playerNode = cells[0].FirstChild;
            if (playerNode.NodeType == HtmlNodeType.Element && playerNode.Name == "a")
            {
                innings.BowlerId = FindPlayerId(playerNode);
            }

            innings.NameOnScorecard = playerNode.InnerText;

            string oversText = GetTrimmedInnerText(cells[1]);
            if (oversText != "?" && oversText != "-")
            {
                string overs = oversText;
                string balls = null;
                int dot = oversText.LastIndexOf('.');
                if (dot >= 0)
                {
                    overs = oversText.Substring(0, dot);
                    balls = oversText.Substring(dot + 1);
                }
                int completedOvers = int.Parse(overs);
                int extraBalls = string.IsNullOrEmpty(balls) ? 0 : int.Parse(balls);

                innings.Overs = string.IsNullOrEmpty(balls) ? completedOvers.ToString() : string.Format("{0}.{1}", completedOvers, extraBalls);
                innings.BallsBowled = (completedOvers * _match.BallsPerOver) + extraBalls;
            }

            string maidensText = GetTrimmedInnerText(cells[2]);
            int maidens;
            if (int.TryParse(maidensText, out maidens))
                innings.Maidens = maidens;

            string runsText = GetTrimmedInnerText(cells[3]);
            int runs;
            if (int.TryParse(runsText, out runs))
                innings.Runs = runs;

            string wicketsText = GetTrimmedInnerText(cells[4]);
            int wickets;
            if (int.TryParse(wicketsText, out wickets))
                innings.Wickets = wickets;

            string widesText = GetTrimmedInnerText(cells[5]);
            int wides;
            if (int.TryParse(widesText, out wides))
                innings.Wides = wides;

            string noballsText = GetTrimmedInnerText(cells[6]);
            int noballs;
            if (int.TryParse(noballsText, out noballs))
                innings.NoBalls = noballs;

            return innings;
        }