Esempio n. 1
0
        public static MvcOptions ConfigureCsvFormatter([NotNull] this MvcOptions thisValue, [NotNull] Action <CsvConfiguration> configureCsv)
        {
            thisValue.RespectBrowserAcceptHeader = true;

            CsvConfiguration settings = new CsvConfiguration(CultureInfo.InvariantCulture);

            configureCsv(settings);

            CsvInputFormatter input = thisValue.InputFormatters.OfType <CsvInputFormatter>()
                                      .FirstOrDefault();

            if (input == null)
            {
                input = new CsvInputFormatter(settings);
                thisValue.InputFormatters.Add(input);
            }

            CsvOutputFormatter output = thisValue.OutputFormatters.OfType <CsvOutputFormatter>()
                                        .FirstOrDefault();

            if (output == null)
            {
                output = new CsvOutputFormatter(settings);
                thisValue.OutputFormatters.Add(output);
            }

            thisValue.FormatterMappings.SetMediaTypeMappingForFormat("csv", MediaTypeHeaderValues.ApplicationCsv);
            return(thisValue);
        }
Esempio n. 2
0
 public void ImportCsv()
 {
     CsvInputFormatter formatter = new CsvInputFormatter(new CsvFormatterOptions()
     {
         CsvDelimiter = ";"
     });
 }