Mono.Csv.CsvFileReader.ReadQuotedColumn C# (CSharp) Méthode

ReadQuotedColumn() private méthode

Reads a quoted column by reading from the current line until a closing quote is found or the end of the file is reached. On return, the current position points to the delimiter or the end of the last line in the file. Note: CurrLine may be set to null on return.
private ReadQuotedColumn ( ) : string
Résultat string
        private string ReadQuotedColumn()
        {
            // Skip opening quote character
            Debug.Assert (CurrPos < CurrLine.Length && CurrLine [CurrPos] == Quote);
            CurrPos++;

            // Parse column
            StringBuilder builder = new StringBuilder ();
            while (true) {
                while (CurrPos == CurrLine.Length) {
                    // End of line so attempt to read the next line
                    CurrLine = Reader.ReadLine ();
                    CurrPos = 0;
                    // Done if we reached the end of the file
                    if (CurrLine == null)
                        return builder.ToString ();
                    // Otherwise, treat as a multi-line field
                    builder.Append (Environment.NewLine);
                }

                // Test for quote character
                if (CurrLine [CurrPos] == Quote) {
                    // If two quotes, skip first and treat second as literal
                    int nextPos = (CurrPos + 1);
                    if (nextPos < CurrLine.Length && CurrLine [nextPos] == Quote)
                        CurrPos++;
                    else
                        break;  // Single quote ends quoted sequence
                }
                // Add current character to the column
                builder.Append (CurrLine [CurrPos++]);
            }

            if (CurrPos < CurrLine.Length) {
                // Consume closing quote
                Debug.Assert (CurrLine [CurrPos] == Quote);
                CurrPos++;
                // Append any additional characters appearing before next delimiter
                builder.Append (ReadUnquotedColumn ());
            }
            // Return column value
            return builder.ToString ();
        }