Exemplo n.º 1
0
 private static DataReaderConfig GetConfig(ClassMapping mapping)
 {
     DataReaderConfig retVal = new DataReaderConfig();
     int colNum = 0;
     foreach (string colName in mapping.AllDataColsInOrder)
     {
         retVal.IndexesByName[colName] = colNum++;
     }
     return retVal;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Create the data reader.
        /// </summary>
        /// <param name="config">The column indexes in the data, keyed by column name.  This may include
        ///                             columns not in the mapping.</param>
        protected CachingDataReader(DataReaderConfig config)
        {
            _config = config;
            _indexesByName = config.IndexesByName;
            // It is possible to be skipping columns, so figure out the highest
            // column index and we'll assume there are that many columns.  It's easier
            // that way than mapping column 5 to 3 when reading just because we skipped a couple.
            int maxColNum = 0;
            foreach (int index in _indexesByName.Values)
            {
                if (index > maxColNum)
                {
                    maxColNum = index;
                }
            }
            _numCols = maxColNum + 1;

            // This will have nulls for skipped columns.
            _namesByIndex = new string[_numCols];
            foreach (KeyValuePair<string, int> indexByName in _indexesByName)
            {
                _namesByIndex[indexByName.Value] = indexByName.Key;
            }
            _valsByIndex = new object[_numCols];
        }