Ejemplo n.º 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());
        }
Ejemplo n.º 2
0
        /// <summary>Retrieves a list of Column maps based on the class property type.
        /// Call this method AFTER calling Init() or the result will be a count of zero.</summary>
        /// <param name="typeOfProperty">A property type</param>
        /// <returns>List of columns with the specified property type.</returns>
        public List <ColumnToPropertyMap> FindColumnsByPropertyType(Type typeOfProperty)
        {
            if (_initialized == false)
            {
                return(new List <ColumnToPropertyMap>());
            }

            return(ColumnMapList
                   .Where(w => w.PropInformation.PropertyType == typeOfProperty)
                   .ToList());
        }
Ejemplo n.º 3
0
        /// <summary>Retrieves a list of Column maps based on the converter being used by the property.
        /// Call this method AFTER calling Init() or the result will be a count of zero.</summary>
        /// <param name="typeOfConverter">Converter type</param>
        /// <returns>List of columns using the converter.</returns>
        public List <ColumnToPropertyMap> FindColumnsByConverterType(Type typeOfConverter)
        {
            if (_initialized == false)
            {
                return(new List <ColumnToPropertyMap>());
            }

            return(ColumnMapList
                   .Where(w => w.ReadConverter.GetType() == typeOfConverter)
                   .ToList());
        }
Ejemplo n.º 4
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);
                }
            }
        }