/// <summary>
        /// Gets the list of Logic Records given a file name
        /// </summary>
        /// <param name="fileName">specifies the file to be read</param>
        /// <returns></returns>
        public static List<LogicRecord> GetLogicRecords(string fileName)
        {
            List<string> allLinesInFile = File.ReadAllLines(fileName).ToList();
            List<LogicRecord> _logicRecords = new List<LogicRecord>();

            foreach (string line in allLinesInFile)
            {
                string[] splitColumns = line.Split(' ');
                LogicRecord logicRecord = new LogicRecord();
                bool success = Enum.TryParse(splitColumns[0], out logicRecord._operator);
                if (success)
                {
                    int lengthOfInput = splitColumns.Length - 1;
                    for (int i = 1; i < lengthOfInput; i++)
                    {
                        int input = int.Parse(splitColumns[i]);
                        logicRecord._inputs.Add(input);
                    }

                    logicRecord._output = int.Parse(splitColumns[splitColumns.Length - 1]);
                    _logicRecords.Add(logicRecord);
                }
            }

            return _logicRecords;
        }
Exemple #2
0
        /// <summary>
        /// Gets the list of Logic Records given a file name
        /// </summary>
        /// <param name="fileName">specifies the file to be read</param>
        /// <returns></returns>
        public static List <LogicRecord> GetLogicRecords(string fileName)
        {
            List <string>      allLinesInFile = File.ReadAllLines(fileName).ToList();
            List <LogicRecord> _logicRecords  = new List <LogicRecord>();

            foreach (string line in allLinesInFile)
            {
                string[]    splitColumns = line.Split(' ');
                LogicRecord logicRecord  = new LogicRecord();
                bool        success      = Enum.TryParse(splitColumns[0], out logicRecord._operator);
                if (success)
                {
                    int lengthOfInput = splitColumns.Length - 1;
                    for (int i = 1; i < lengthOfInput; i++)
                    {
                        int input = int.Parse(splitColumns[i]);
                        logicRecord._inputs.Add(input);
                    }

                    logicRecord._output = int.Parse(splitColumns[splitColumns.Length - 1]);
                    _logicRecords.Add(logicRecord);
                }
            }

            return(_logicRecords);
        }