/// <summary> /// Reads a line of the CSV file. /// </summary> /// <returns>The CSV line.</returns> protected virtual string[] ReadLine() { context.RecordBuilder.Clear(); context.Row++; context.RawRow++; while (true) { if (fieldReader.IsBufferEmpty && !fieldReader.FillBuffer()) { // End of file. if (context.RecordBuilder.Length > 0) { // There was no line break at the end of the file. // We need to return the last record first. context.RecordBuilder.Add(fieldReader.GetField()); return(context.RecordBuilder.ToArray()); } return(null); } c = fieldReader.GetChar(); if (context.RecordBuilder.Length == 0 && ((c == context.ParserConfiguration.Comment && context.ParserConfiguration.AllowComments) || c == '\r' || c == '\n')) { ReadBlankLine(); if (!context.ParserConfiguration.IgnoreBlankLines) { break; } continue; } // Trim start outside of quotes. if (c == ' ' && (context.ParserConfiguration.TrimOptions & TrimOptions.Trim) == TrimOptions.Trim) { ReadSpaces(); fieldReader.SetFieldStart(-1); } if (c == context.ParserConfiguration.Quote && !context.ParserConfiguration.IgnoreQuotes) { if (ReadQuotedField()) { break; } } else { if (ReadField()) { break; } } } return(context.RecordBuilder.ToArray()); }