예제 #1
0
 public LookUpDataReader(string category, string lookUpFilePath, int keyColumn, int nameColumn)
 {
     _filePath                       = lookUpFilePath;
     _textReader                     = File.OpenText(_filePath);
     _category                       = category;
     _currentLookUpRecord            = new LookUp();
     _currentLookUpRecord.RecordType = category;
     _keyColumn                      = keyColumn;
     _nameColumn                     = nameColumn;
     _fileLength                     = _textReader.BaseStream.Length;
     currentPosition                 = 0;
 }
예제 #2
0
        public bool Read()
        {
            string currentLine = null;

            if (_recordCount == 0)
            {
                //read the header row and ignore
                currentLine     = _textReader.ReadLine();
                currentPosition = _textReader.BaseStream.Position;
            }
            while (!_textReader.EndOfStream)
            {
                currentLine     = _textReader.ReadLine();
                currentPosition = _textReader.BaseStream.Position;
                if (_textReader.EndOfStream)
                {
                    return(false);
                }
                else
                {
                    string[] items = currentLine.Split('\t');
                    //if key or name is null move to next record.
                    if (string.IsNullOrEmpty(items[_keyColumn]) || string.IsNullOrEmpty(items[_nameColumn]))
                    {
                    }
                    else
                    {
                        _currentLookUpRecord = new LookUp()
                        {
                            LookUpKey = items[_keyColumn], Name = items[_nameColumn], RecordType = _category
                        };
                        _recordCount++;
                        return(true);
                    }
                }
            }
            return(false);
        }