Example #1
0
        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;
            }
        }
Example #2
0
 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;
 }
Example #3
0
 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;
 }
Example #4
0
 public SeparatedValueRecordParser(RetryReader reader, SeparatedValueOptions options)
 {
     this.reader                 = reader;
     this.options                = options.Clone();
     this.separatorMatcher       = SeparatorMatcher.GetMatcher(reader, options.Separator);
     this.recordSeparatorMatcher = SeparatorMatcher.GetMatcher(reader, options.RecordSeparator);
     if (options.RecordSeparator != null && options.RecordSeparator.StartsWith(options.Separator))
     {
         string postfix = options.RecordSeparator.Substring(options.Separator.Length);
         this.postfixMatcher = SeparatorMatcher.GetMatcher(reader, postfix);
     }
     this.separatorLength = Math.Max(this.options.RecordSeparator?.Length ?? 2, this.options.Separator.Length);
     this.tokens          = new List <string>();
     this.token           = new StringBuilder();
 }
Example #5
0
 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;
 }
Example #6
0
 /// <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)
 {
 }
Example #7
0
 /// <summary>
 /// Initializes a new SeparatedValueComplexColumn with the given options.
 /// </summary>
 /// <param name="columnName">The name of the column.</param>
 /// <param name="options">The options to use when parsing the embedded data.</param>
 public SeparatedValueComplexColumn(string columnName, SeparatedValueOptions options)
     : this(columnName, null, options, false)
 {
 }
Example #8
0
 /// <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)
 {
 }
Example #9
0
 /// <summary>
 /// Initializes a new SeparatedValueReader with no schema.
 /// </summary>
 /// <param name="reader">A reader over 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>
 public SeparatedValueReader(TextReader reader, SeparatedValueOptions options = null)
     : this(reader, null, options, false)
 {
 }
Example #10
0
 /// <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)
 {
 }
Example #11
0
 /// <summary>
 /// Initializes a new SeparatedValueWriter without a schema.
 /// </summary>
 /// <param name="writer">A writer over the separated value document.</param>
 /// <param name="options">The options used to format the output.</param>
 /// <exception cref="ArgumentNullException">The writer is null.</exception>
 public SeparatedValueWriter(TextWriter writer, SeparatedValueOptions options = null)
     : this(writer, null, options, false)
 {
 }