Пример #1
0
        /// <summary>
        /// Read ballot.csv.
        /// </summary>
        private Ballot[] ReadBallots(string ballotFile)
        {
            if (!File.Exists(ballotFile))
            {
                return(new Ballot[0]);
            }

            List <Ballot> ballots = new List <Ballot>();
            FileInfo      file    = new FileInfo(ballotFile);

            using (TextReader reader = file.OpenText())
            {
                CsvReader csv = new CsvReader(reader);
                while (csv.Read())
                {
                    ballots.Add(Ballot.FromFields(csv.CurrentRecord, this));
                }
            }

            return(ballots.ToArray());
        }