Beispiel #1
0
        /*
         * Reads from file
         */
        public override void readFromFile()
        {
            StreamReader reader = new StreamReader(fileName);

            while (!reader.EndOfStream)
            {
                String   line   = reader.ReadLine();
                String[] tokens = line.Split('#');
                if (tokens.Length == 2)
                {
                    OptionFormatValidator.validateFormat(tokens[0], tokens[1]);
                    Option option = new Option(int.Parse(tokens[0]), int.Parse(tokens[1]));
                    base.saveInMemory(option);
                }
            }
            reader.Close();
        }
 /*
  * Formats the id
  * Throws ValidatorException
  */
 public override Pair <int, int> formatId(string id)
 {
     OptionFormatValidator.validateId(id);
     string[] tokens = id.Split(' ');
     return(new Pair <int, int>(int.Parse(tokens[0]), int.Parse(tokens[1])));
 }
 /*
  * Formats an element
  * Throws ValidatorException if format is invalid
  */
 public override Option formatElement(params string[] fields)
 {
     OptionFormatValidator.validateFormat(fields);
     return(new Option(int.Parse(fields[0]), int.Parse(fields[1])));
 }