コード例 #1
0
ファイル: CsvFiles.cs プロジェクト: calvarycat/BateGon
 public static void ToCsv <T>(this IEnumerable <T> source, CsvDestination csvDestination,
                              CsvDefinition csvDefinition)
 {
     using (var csvFile = new CsvFile <T>(csvDestination, csvDefinition))
     {
         foreach (var record in source)
         {
             csvFile.Append(record);
         }
     }
 }
コード例 #2
0
ファイル: CsvFiles.cs プロジェクト: calvarycat/BateGon
 static CsvFile()
 {
     // Choosing default Field Separator is a hard decision
     // In theory the C of CSV means Comma separated
     // In Windows though many people will try to open the csv with Excel which is horrid with real CSV.
     // As the target for this library is Windows we go for Semi Colon.
     DefaultCsvDefinition = new CsvDefinition
     {
         EndOfLine      = "\r\n",
         FieldSeparator = ',',
         TextQualifier  = '"'
     };
     UseLambdas     = true;
     UseTasks       = false;
     FastIndexOfAny = true;
 }
コード例 #3
0
ファイル: CsvFiles.cs プロジェクト: calvarycat/BateGon
        public CsvFileReader(CsvSource csvSource, CsvDefinition csvDefinition)
        {
            var streamReader = csvSource.TextReader as StreamReader;

            if (streamReader != null)
            {
                BaseStream = streamReader.BaseStream;
            }
            if (csvDefinition == null)
            {
                csvDefinition = DefaultCsvDefinition;
            }
            fieldSeparator = csvDefinition.FieldSeparator;
            textQualifier  = csvDefinition.TextQualifier;

            textReader = csvSource.TextReader; // new FileStream(csvSource.TextReader, FileMode.Open);

            ReadHeader(csvDefinition.Header);
        }