예제 #1
0
        /// <summary>
        /// Reads the input file specified by InputPath.
        /// </summary>
        private void readSequence()
        {
            // Can't do anything if the file doesn't exist.
            if (!File.Exists(InputPath))
            {
                throw new FileNotFoundException("The specified mock file does not exist.", InputPath);
            }

            // Open a reader.
            StreamReader reader = new StreamReader(InputPath);
            // Make a line, the item that will be read, and the lineNumber, which
            // will be used for error reports if there are any.
            string line; HandData item; int lineNumber = 0;

            while (reader.Peek() != -1)
            {
                lineNumber++;
                line = reader.ReadLine();
                item = new HandData();
                item.Populate(line);
                sequence.Add(item);
            }
            if (sequence.Count == 0)
            {
                throw new MalformedException("The mock emulation file did not contain any valid data.");
            }
            reader.Close();
            reader.Dispose();
        }