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(Resources.SameSeparator, nameof(options)); } RetryReader retryReader = new RetryReader(reader); parser = new SeparatedValueRecordParser(retryReader, options); metadata = new SeparatedValueRecordContext() { ExecutionContext = new SeparatedValueExecutionContext() { Schema = hasSchema ? schema : null, Options = parser.Options } }; }
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; } }
public SeparatedValueRecordParser(RetryReader reader, SeparatedValueOptions options) { this.reader = reader; Options = options.Clone(); separatorMatcher = SeparatorMatcher.GetMatcher(reader, options.Separator); recordSeparatorMatcher = SeparatorMatcher.GetMatcher(reader, options.RecordSeparator); if (options.RecordSeparator != null && options.RecordSeparator.StartsWith(options.Separator)) { string postfix = options.RecordSeparator.Substring(options.Separator.Length); postfixMatcher = SeparatorMatcher.GetMatcher(reader, postfix); } separatorLength = Math.Max(Options.RecordSeparator?.Length ?? 2, Options.Separator.Length); }
public SeparatedValueRecordParser(RetryReader reader, SeparatedValueOptions options) { this.reader = reader; this.options = options.Clone(); this.separatorMatcher = getMatcher(options.Separator); this.recordSeparatorMatcher = getMatcher(options.RecordSeparator); if (options.RecordSeparator.StartsWith(options.Separator)) { string postfix = options.RecordSeparator.Substring(options.Separator.Length); this.postfixMatcher = getMatcher(postfix); } this.token = new StringBuilder(); }
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(); }
public static ISeparatorMatcher GetMatcher(RetryReader reader, string separator) { if (separator == null) { return(new DefaultSeparatorMatcher(reader)); } else if (separator.Length == 1) { return(new OneCharacterSeparatorMatcher(reader, separator[0])); } else if (separator.Length == 2) { return(new TwoCharacterSeparatorMatcher(reader, separator[0], separator[1])); } else { return(new StringSeparatorMatcher(reader, separator)); } }
private SeparatedValueReader(TextReader reader, SeparatedValueSchema schema, SeparatedValueOptions options, bool hasSchema) { if (reader == null) { throw new ArgumentNullException("reader"); } if (hasSchema && schema == null) { throw new ArgumentNullException("schema"); } if (options == null) { options = new SeparatedValueOptions(); } if (options.RecordSeparator == options.Separator) { throw new ArgumentException(SharedResources.SameSeparator, "options"); } RetryReader retryReader = new RetryReader(reader); this.parser = new SeparatedValueRecordParser(retryReader, options); if (hasSchema) { if (options.IsFirstRecordSchema) { skip(); // 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); } } }
public SeparatorRecordReader(TextReader reader, string separator) { this.reader = new RetryReader(reader); this.matcher = SeparatorMatcher.GetMatcher(this.reader, separator); this.builder = new StringBuilder(); }
public Matcher(RetryReader reader, string separator) { this.reader = reader; this.separator = separator; }
public Matcher2(RetryReader reader, char first, char second) { this.reader = reader; this.first = first; this.second = second; }
public Matcher1(RetryReader reader, char first) { this.reader = reader; this.first = first; }
public RetryState(RetryReader reader) { this.reader = reader; this.retry = reader.retry; }
public ReaderState(RetryReader reader) { this.reader = reader; this.textReader = reader.reader; }
public TwoCharacterSeparatorMatcher(RetryReader reader, char first, char second) { this.reader = reader; this.first = first; this.second = second; }
public OneCharacterSeparatorMatcher(RetryReader reader, char first) { this.reader = reader; this.first = first; }
public DefaultSeparatorMatcher(RetryReader reader) { this.reader = reader; }