Example #1
0
        /// <summary>Creates the column to property mapper</summary>
        protected override void CreateMappings()
        {
            ColumnMapList.Clear();
            var mapper = new ColumnToPropertyMapper <T>(Configuration, DefaultConverterFactory, ColumnIndexDefaultValue);

            ColumnMapList.AddRange(mapper.CreateWriteMap());
        }
Example #2
0
        /// <summary>Creates the mappings necessary for each property.</summary>
        /// <returns></returns>
        protected override void CreateMappings()
        {
            ColumnMapList.Clear();
            _columnDictionary.Clear();

            // Retrieve the header row if the file has one!
            List <string> headerColumns = Configuration.HasHeaderRow ? _rowReader.ReadRow() : new List <string>();

            // Map the class properties to a mapper
            var mapper = new ColumnToPropertyMapper <T>(Configuration, DefaultConverterFactory, ColumnIndexDefaultValue);

            ColumnMapList.AddRange(mapper.CreateReadMap(headerColumns));

            // Map all the columns into a dictionary
            foreach (ColumnToPropertyMap map in ColumnMapList)
            {
                if (map.ColumnIndex > 0)
                {
                    _columnDictionary.Add(map.ColumnIndex, map);
                }
            }
        }