private SeparatedValueReader(TextReader reader, SeparatedValueSchema schema, SeparatedValueOptions options, bool hasSchema) { if (reader == null) { throw new ArgumentNullException(nameof(reader)); } if (hasSchema && schema == null) { throw new ArgumentNullException(nameof(schema)); } if (options == null) { options = new SeparatedValueOptions(); } if (options.RecordSeparator == options.Separator) { throw new ArgumentException(SharedResources.SameSeparator, nameof(options)); } RetryReader retryReader = new RetryReader(reader); this.parser = new SeparatedValueRecordParser(retryReader, options); if (hasSchema) { this.schema = schema; } }
private async Task handleSchemaAsync() { if (recordCount != 0) { return; } if (!parser.Options.IsFirstRecordSchema) { return; } if (schema != null) { await skipAsync(); return; } string[] columnNames = await readNextRecordAsync(); schema = new SeparatedValueSchema(); foreach (string columnName in columnNames) { StringColumn column = new StringColumn(columnName); schema.AddColumn(column); } }
public SeparatedValueRecordWriter(TextWriter writer, SeparatedValueSchema schema, SeparatedValueOptions options) { this.writer = writer; this.schema = schema; this.options = options.Clone(); this.quoteString = String.Empty + options.Quote; this.doubleQuoteString = String.Empty + options.Quote + options.Quote; }
private SeparatedValueComplexColumn(string columnName, SeparatedValueSchema schema, SeparatedValueOptions options, bool hasSchema) : base(columnName) { if (hasSchema && schema == null) { throw new ArgumentNullException("schema"); } if (options == null) { throw new ArgumentNullException("options"); } this.schema = schema; this.options = options; }
private SeparatedValueWriter(TextWriter writer, SeparatedValueSchema schema, SeparatedValueOptions options, bool hasSchema) { if (writer == null) { throw new ArgumentNullException("writer"); } if (hasSchema && schema == null) { throw new ArgumentNullException("schema"); } if (options == null) { options = new SeparatedValueOptions(); } this.recordWriter = new SeparatedValueRecordWriter(writer, schema, options); this.isFirstLine = true; }
/// <summary> /// Initializes a new SeparatedValueComplexColumn with the given schema and options. /// </summary> /// <param name="columnName">The name of the column.</param> /// <param name="schema">The schema of the data embedded in the column.</param> /// <param name="options">The options to use when parsing the embedded data.</param> public SeparatedValueComplexColumn(string columnName, SeparatedValueSchema schema, SeparatedValueOptions options) : this(columnName, schema, options, true) { }
/// <summary> /// Initializes a new SeparatedValueComplexColumn with the given schema and default options. /// </summary> /// <param name="columnName">The name of the column.</param> /// <param name="schema">The schema of the data embedded in the column.</param> public SeparatedValueComplexColumn(string columnName, SeparatedValueSchema schema) : this(columnName, schema, new SeparatedValueOptions(), true) { }
/// <summary> /// Initializes a new SeparatedValueReader with the given schema. /// </summary> /// <param name="reader">A reader over the separated value document.</param> /// <param name="schema">The schema of the separated value document.</param> /// <param name="options">The options controlling how the separated value document is read.</param> /// <exception cref="ArgumentNullException">The reader is null.</exception> /// <exception cref="ArgumentNullException">The schema is null.</exception> public SeparatedValueReader(TextReader reader, SeparatedValueSchema schema, SeparatedValueOptions options = null) : this(reader, schema, options, true) { }
/// <summary> /// Initializes a new SeparatedValueWriter with the given schema. /// </summary> /// <param name="writer">A writer over the separated value document.</param> /// <param name="schema">The schema of the separated value document.</param> /// <param name="options">The options used to format the output.</param> /// <exception cref="ArgumentNullException">The writer is null.</exception> /// <exception cref="ArgumentNullException">The schema is null.</exception> public SeparatedValueWriter(TextWriter writer, SeparatedValueSchema schema, SeparatedValueOptions options = null) : this(writer, schema, options, true) { }