Пример #1
0
        internal CsvConfiguration GetCurrentConfiguration()
        {
            var currentConfiguration = new CsvConfiguration
            {
                Delimiter        = FieldDelimiter.GetValue().ToString(),
                SkipEmptyRecords = true,
                Quote            = '█' //,
                                       //QuoteNoFields = true
            };
            var allProperties = CurrentInterchangeRecordType.GetProperties();

            //map all the public properties with their indexes.
            foreach (var propertyInfo in allProperties)
            {
                var currentPropertyInfo = propertyInfo;
                var mapping             = CurrentFieldMappings.Keys.SingleOrDefault(p => p == currentPropertyInfo.Name);
                //if the mapping does not exit or equals -1, ignore it.
                if (mapping == null || CurrentFieldMappings[mapping] == -1)
                {
                    currentConfiguration.PropertyMap(currentPropertyInfo).Ignore();
                }
                else
                {
                    currentConfiguration.Properties.Add(
                        currentConfiguration.PropertyMap(currentPropertyInfo).Index(CurrentFieldMappings[mapping]));
                }
            }

            return(currentConfiguration);
        }