Esempio n. 1
0
        /// <summary>
        /// Maps a property to a CSV field.
        /// </summary>
        /// <param name="property">The property to map.</param>
        /// <returns>The property mapping.</returns>
        public virtual CsvPropertyMap Map(PropertyInfo property)
        {
            var existingMap = PropertyMaps.Find(property);

            if (existingMap != null)
            {
                return(existingMap);
            }

            var propertyMap = new CsvPropertyMap(property);

            propertyMap.Data.Index = GetMaxIndex() + 1;
            PropertyMaps.Add(propertyMap);

            return(propertyMap);
        }
Esempio n. 2
0
        /// <summary>
        /// Maps a property/field to a CSV field.
        /// </summary>
        /// <param name="member">The property/field to map.</param>
        /// <param name="useExistingMap">If true, an existing map will be used if available.
        /// If false, a new map is created for the same property/field.</param>
        /// <returns>The property/field mapping.</returns>
        public virtual CsvPropertyMap Map(MemberInfo member, bool useExistingMap = true)
        {
            if (useExistingMap)
            {
                var existingMap = PropertyMaps.Find(member);
                if (existingMap != null)
                {
                    return(existingMap);
                }
            }

            var propertyMap = new CsvPropertyMap(member);

            propertyMap.Data.Index = GetMaxIndex() + 1;
            PropertyMaps.Add(propertyMap);

            return(propertyMap);
        }
Esempio n. 3
0
        /// <summary>
        /// Maps a property/field to a CSV field.
        /// </summary>
        /// <param name="classType">The type of the class this map is for. This may not be the same type
        /// as the member.DeclaringType or the current ClassType due to nested property mappings.</param>
        /// <param name="member">The property/field to map.</param>
        /// <param name="useExistingMap">If true, an existing map will be used if available.
        /// If false, a new map is created for the same property/field.</param>
        /// <returns>The property/field mapping.</returns>
        public CsvPropertyMap Map(Type classType, MemberInfo member, bool useExistingMap = true)
        {
            if (useExistingMap)
            {
                var existingMap = PropertyMaps.Find(member);
                if (existingMap != null)
                {
                    return(existingMap);
                }
            }

            var propertyMap = CsvPropertyMap.CreateGeneric(classType, member);

            propertyMap.Data.Index = GetMaxIndex() + 1;
            PropertyMaps.Add(propertyMap);

            return(propertyMap);
        }