示例#1
0
 public CsvFile(string path,
                Encoding encoding,
                bool writeHeader = true,
                int buffer       = 3600,
                bool append      = true,
                char delimeter   = ';'
                )
 {
     FileWriter = new StreamWriter(
         path,
         append,
         encoding,
         buffer
         );
     config = new CsvConfig(delimeter);
     if (writeHeader)
     {
         FileWriter.WriteLine(
             CsvFunctions.ToHeader(
                 typeof(T),
                 config
                 )
             );
     }
 }
示例#2
0
 public Task WriteLineAsync(T lineElement)
 {
     return(FileWriter.WriteLineAsync(
                CsvFunctions.ToLine(
                    lineElement,
                    config
                    )
                ));
 }
示例#3
0
        public async Task WriteLinesAsync(IEnumerable <T> elements)
        {
            var enumerator = elements.GetEnumerator();

            while (enumerator.MoveNext())
            {
                await FileWriter.WriteLineAsync(
                    CsvFunctions.ToLine(
                        enumerator.Current,
                        config
                        )
                    );
            }
        }