private FixedLengthReader(Stream stream, FixedLengthSchema schema, FixedLengthOptions options, bool ownsStream) { if (stream == null) { throw new ArgumentNullException("stream"); } if (schema == null) { throw new ArgumentNullException("schema"); } if (options == null) { throw new ArgumentNullException("options"); } reader = new RecordReader(stream, options.Encoding, options.RecordSeparator, ownsStream); this.schema = schema; this.options = options.Clone(); }
private SeparatedValueReader(Stream stream, SeparatedValueSchema schema, SeparatedValueOptions options, bool hasSchema, bool ownsStream) { if (stream == null) { throw new ArgumentNullException("stream"); } if (hasSchema && schema == null) { throw new ArgumentNullException("schema"); } if (options == null) { throw new ArgumentNullException("options"); } reader = new RecordReader(stream, options.Encoding, options.RecordSeparator, ownsStream); 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 SeparatedValueSchema(); foreach (string columnName in columnNames) { StringColumn column = new StringColumn(columnName); this.schema.AddColumn(column); } } }