private SeparatedValueParser(Stream stream, Schema schema, SeparatedValueParserOptions options, bool hasSchema) { if (stream == null) { throw new ArgumentNullException("stream"); } if (hasSchema && schema == null) { throw new ArgumentNullException("schema"); } if (options == null) { throw new ArgumentNullException("options"); } this.stream = stream; StreamReader reader = new StreamReader(stream); this.text = reader.ReadToEnd(); regex = buildRegex(options.Separator); if (hasSchema) { if (options.IsFirstRecordSchema) { readNextRecord(); // skip header record } this.schema = schema; } else if (options.IsFirstRecordSchema) { string[] columnNames = readNextRecord(); this.schema = new Schema(); foreach (string columnName in columnNames) { StringColumn column = new StringColumn(columnName); this.schema.AddColumn(column); } } }