Ejemplo n.º 1
0
 public BowlingScore(string id, string score, InningScore innings)
 {
     ID       = id;
     Score    = score;
     Innnings = innings;
 }
Ejemplo n.º 2
0
        private static CricketScore CreateCricketScore(KeyValuePair <string, object> match)
        {
            var scorePair = match.Value as Dictionary <string, object>;

            try
            {
                var scoreMatch = (scorePair["score"] as Dictionary <string, object>);
                if (scoreMatch != null)
                {
                    //batting

                    var battingObj   = scoreMatch["batting"] as Dictionary <string, object>;
                    var battingId    = GetProperty(battingObj, "id");
                    var battingScore = GetProperty(battingObj, "score");

                    var battingInningScoreArray = battingObj["innings"] as ArrayList;
                    var battingInningScore      = battingInningScoreArray[0] as Dictionary <string, object>;

                    var batInningId    = GetProperty(battingInningScore, "id");
                    var wicketsBatting = GetProperty(battingInningScore, "wkts");
                    var inningScore    = GetProperty(battingInningScore, "score");
                    var overs          = GetProperty(battingInningScore, "overs");


                    InningScore  batInnings   = new InningScore(batInningId, inningScore, wicketsBatting, overs);
                    BattingScore BattingScore = new BattingScore(battingId, battingScore, batInnings);

                    //bowling
                    var bowlingObj   = scoreMatch["bowling"] as Dictionary <string, object>;
                    var bowlingId    = GetProperty(bowlingObj, "id");
                    var bowlingScore = GetProperty(bowlingObj, "score");

                    var         bowlingInningScoreArray = bowlingObj["innings"] as ArrayList;
                    InningScore bowlInnings;
                    if (bowlingInningScoreArray.Count > 0)
                    {
                        var bowlingInningScore = bowlingInningScoreArray[0] as Dictionary <string, object>;

                        var bowlInningId    = GetProperty(bowlingInningScore, "id");
                        var wicketsbowling  = GetProperty(bowlingInningScore, "wkts");
                        var inningBowlScore = GetProperty(bowlingInningScore, "score");
                        var BowlOvers       = GetProperty(bowlingInningScore, "overs");

                        bowlInnings = new InningScore(bowlInningId, inningBowlScore, wicketsbowling, BowlOvers);
                    }

                    bowlInnings = null;
                    BowlingScore BowlingScore = new BowlingScore(bowlingId, bowlingScore, bowlInnings);

                    //Get current BatsMen
                    List <CricketBatsman> batsmen = CreateCurrentCricketBatsmen(scoreMatch);

                    //Get current bowlers
                    List <CricketBowler> bowlers = CreateCurrentCricketBowler(scoreMatch);

                    //get crr
                    var crr      = GetProperty(scoreMatch, "crr");
                    var pre_over = GetProperty(scoreMatch, "prev_overs");
                    var target   = GetProperty(scoreMatch, "target");

                    //part
                    var p = CreateCricketPartnership(scoreMatch);

                    return(new CricketScore(BattingScore, BowlingScore, batsmen, bowlers, crr
                                            , pre_over, target, p));
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception e)
            {
                //Console.WriteLine(e);
                return(null);
            }
        }