Esempio n. 1
0
        private void ReadScoreLog()
        {
            List <string> robotLines;
            List <string> teamLines;

            using (var scoreLog = File.ReadAllLines(ScoreLogFile).AsEnumerable().GetEnumerator()) {
                scoreLog.SkipUntil(line => line.StartsWith("____Robots"));
                robotLines = scoreLog.Take(Int32.Parse(GetCsvValue(scoreLog.Current, "____Robots"))).ToList();
                teamLines  = scoreLog.Take(Int32.Parse(GetCsvValue(scoreLog.Current, "____Teams"))).ToList();
            }

            int id = 0;

            var robotsByName = (from robotLine in robotLines
                                let split = robotLine.Split(',')
                                            select new RobotResult(id++)
            {
                Name = split[0],
                Version = split[1],
                Author = split[2],
                FileName = split[3],
                TotalScore = Int32.Parse(split[4]),
                Places = split.Skip(5).Select(Int32.Parse).ToArray()
            }).ToDictionary(r => r.Name);

            foreach (var teamLine in teamLines)
            {
                var split = teamLine.Split(',');
                var team  = new TeamResult {
                    Name       = split[0],
                    TotalScore = Int32.Parse(split[1])
                };
                Teams.Add(team);
                team.Robots.AddRange(
                    from name in split.Skip(3)
                    select robotsByName[name]);
            }
        }
        private void ReadScoreLog()
        {
            List<string> robotLines;
            List<string> teamLines;
            using (var scoreLog = File.ReadAllLines(ScoreLogFile).AsEnumerable().GetEnumerator()) {
                scoreLog.SkipUntil(line => line.StartsWith("____Robots"));
                robotLines = scoreLog.Take(Int32.Parse(GetCsvValue(scoreLog.Current, "____Robots"))).ToList();
                teamLines = scoreLog.Take(Int32.Parse(GetCsvValue(scoreLog.Current, "____Teams"))).ToList();
            }

            int id = 0;

            var robotsByName = (from robotLine in robotLines
                                                            let split = robotLine.Split(',')
                                                            select new RobotResult(id++) {
                                                                Name = split[0],
                                                                Version = split[1],
                                                                Author = split[2],
                                                                FileName = split[3],
                                                                TotalScore = Int32.Parse(split[4]),
                                                                Places = split.Skip(5).Select(Int32.Parse).ToArray()
                                                            }).ToDictionary(r => r.Name);

            foreach (var teamLine in teamLines) {
                var split = teamLine.Split(',');
                var team = new TeamResult {
                    Name = split[0],
                    TotalScore = Int32.Parse(split[1])
                };
                Teams.Add(team);
                team.Robots.AddRange(
                    from name in split.Skip(3)
                    select robotsByName[name]);
            }
        }