예제 #1
0
        private static IWriterConfiguration CreateCsvWriterConfiguration()
        {
            IWriterConfiguration writerConfiguration = new CsvConfiguration(CultureInfo.CurrentCulture);

            foreach (Type classMapType in CsvClassMapHelper.GetAllConcreteTypesAssignableFromCsvClassMap())
            {
                writerConfiguration.RegisterClassMap(classMapType);
            }

            writerConfiguration.IncludePrivateMembers = true;
            writerConfiguration.Delimiter             = ";";
            writerConfiguration.TrimOptions           = TrimOptions.Trim;
            writerConfiguration.SanitizeForInjection  = true;
            //writerConfiguration.ShouldQuote = (field, context) => true;

            return(writerConfiguration);
        }
        private static IReaderConfiguration CreateCsvReaderConfiguration()
        {
            IReaderConfiguration readerConfiguration = new CsvConfiguration(CultureInfo.CurrentCulture);

            foreach (Type classMapType in CsvClassMapHelper.GetAllConcreteTypesAssignableFromCsvClassMap())
            {
                readerConfiguration.RegisterClassMap(classMapType);
            }

            readerConfiguration.IncludePrivateMembers = true;
            readerConfiguration.TrimOptions           = TrimOptions.Trim;

            // Ignore Missing Field
            readerConfiguration.MissingFieldFound = (headerNames, index, context) => { };

            return(readerConfiguration);
        }