コード例 #1
0
 public FixedLengthRecordWriter(TextWriter writer, FixedLengthSchema schema, FixedLengthOptions options)
 {
     this.writer   = writer;
     this.metadata = new FixedLengthWriterMetadata()
     {
         Schema  = schema,
         Options = options.Clone()
     };
 }
コード例 #2
0
 public FixedLengthRecordParser(TextReader reader, FixedLengthSchema schema, FixedLengthOptions options)
 {
     if (options.HasRecordSeparator)
     {
         this.recordReader = new SeparatorRecordReader(reader, options.RecordSeparator);
     }
     else
     {
         this.recordReader = new FixedLengthRecordReader(reader, schema.TotalWidth);
     }
 }
コード例 #3
0
 public FixedLengthRecordParser(TextReader reader, FixedLengthSchema schema, FixedLengthOptions options)
 {
     if (String.IsNullOrEmpty(options.RecordSeparator))
     {
         this.recordReader = new FixedLengthRecordReader(reader, schema.TotalWidth);
     }
     else
     {
         this.recordReader = new SeparatorRecordReader(reader, options.RecordSeparator);
     }
 }
コード例 #4
0
 public FixedLengthRecordWriter(TextWriter writer, FixedLengthSchema schema, FixedLengthOptions options)
 {
     this.writer = writer;
     Metadata    = new FixedLengthRecordContext()
     {
         ExecutionContext = new FixedLengthExecutionContext()
         {
             Schema  = schema,
             Options = options.Clone()
         }
     };
 }
コード例 #5
0
 /// <summary>
 /// Initializes a new FixedLengthComplexColumn 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 FixedLengthComplexColumn(string columnName, FixedLengthSchema schema, FixedLengthOptions options)
     : base(columnName)
 {
     if (schema == null)
     {
         throw new ArgumentNullException("schema");
     }
     if (options == null)
     {
         throw new ArgumentNullException("options");
     }
     this.schema = schema;
     this.options = options.Clone();
 }
コード例 #6
0
 /// <summary>
 /// Initializes a new FixedLengthComplexColumn 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 FixedLengthComplexColumn(string columnName, FixedLengthSchema schema, FixedLengthOptions options)
     : base(columnName)
 {
     if (schema == null)
     {
         throw new ArgumentNullException("schema");
     }
     if (options == null)
     {
         throw new ArgumentNullException("options");
     }
     this.schema  = schema;
     this.options = options.Clone();
 }
コード例 #7
0
 public FixedLengthRecordParser(TextReader reader, FixedLengthSchema schema, FixedLengthOptions options)
 {
     if (options.HasRecordSeparator)
     {
         recordReader = new SeparatorRecordReader(reader, options.RecordSeparator);
     }
     else if (schema == null)
     {
         throw new FlatFileException(Resources.RecordSeparatorRequired);
     }
     else
     {
         recordReader = new FixedLengthRecordReader(reader, schema.TotalWidth);
     }
 }
コード例 #8
0
ファイル: FixedLengthWriter.cs プロジェクト: hbdbim/FlatFiles
 /// <summary>
 /// Initializes a new FixedLengthBuilder with the given schema.
 /// </summary>
 /// <param name="writer">A writer over the fixed-length document.</param>
 /// <param name="schema">The schema of the fixed-length 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 FixedLengthWriter(TextWriter writer, FixedLengthSchema schema, FixedLengthOptions options = null)
 {
     if (writer == null)
     {
         throw new ArgumentNullException(nameof(writer));
     }
     if (schema == null)
     {
         throw new ArgumentNullException(nameof(schema));
     }
     if (options == null)
     {
         options = new FixedLengthOptions();
     }
     recordWriter = new FixedLengthRecordWriter(writer, schema, options);
 }
コード例 #9
0
ファイル: FixedLengthWriter.cs プロジェクト: hbdbim/FlatFiles
 /// <summary>
 /// Initializes a new FixedLengthBuilder with the given schema.
 /// </summary>
 /// <param name="writer">A writer over the fixed-length document.</param>
 /// <param name="injector">The schema injector to use to determine the schema.</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 injector is null.</exception>
 public FixedLengthWriter(TextWriter writer, FixedLengthSchemaInjector injector, FixedLengthOptions options = null)
 {
     if (writer == null)
     {
         throw new ArgumentNullException(nameof(writer));
     }
     if (injector == null)
     {
         throw new ArgumentNullException(nameof(injector));
     }
     if (options == null)
     {
         options = new FixedLengthOptions();
     }
     recordWriter = new FixedLengthRecordWriter(writer, injector, options);
 }
コード例 #10
0
 /// <summary>
 /// Initializes a new FixedLengthBuilder with the given schema.
 /// </summary>
 /// <param name="writer">A writer over the fixed-length document.</param>
 /// <param name="schema">The schema of the fixed-length 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 FixedLengthWriter(TextWriter writer, FixedLengthSchema schema, FixedLengthOptions options = null)
 {
     if (writer == null)
     {
         throw new ArgumentNullException("writer");
     }
     if (schema == null)
     {
         throw new ArgumentNullException("schema");
     }
     if (options == null)
     {
         options = new FixedLengthOptions();
     }
     this.recordWriter = new FixedLengthRecordWriter(writer, schema, options);
     this.isFirstLine  = true;
 }
コード例 #11
0
 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();
 }
コード例 #12
0
 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();
 }
コード例 #13
0
 /// <summary>
 /// Initializes a new FixedLengthReader with the given schema.
 /// </summary>
 /// <param name="reader">A reader over the fixed-length document.</param>
 /// <param name="schema">The schema of the fixed-length document.</param>
 /// <param name="options">The options controlling how the fixed-length document is read.</param>
 /// <exception cref="ArgumentNullException">The reader is null.</exception>
 /// <exception cref="ArgumentNullException">The schema is null.</exception>
 public FixedLengthReader(TextReader reader, FixedLengthSchema schema, FixedLengthOptions options = null)
 {
     if (reader == null)
     {
         throw new ArgumentNullException("reader");
     }
     if (schema == null)
     {
         throw new ArgumentNullException("schema");
     }
     if (options == null)
     {
         options = new FixedLengthOptions();
     }
     parser       = new FixedLengthRecordParser(reader, schema, options);
     this.schema  = schema;
     this.options = options.Clone();
 }
コード例 #14
0
 private FixedLengthWriter(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");
     }
     this.writer = new StreamWriter(stream, options.Encoding ?? Encoding.Default);
     this.schema = schema;
     this.ownsStream = ownsStream;
     this.options = options.Clone();
 }
コード例 #15
0
 private FixedLengthWriter(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");
     }
     this.writer     = new StreamWriter(stream, options.Encoding ?? Encoding.Default);
     this.schema     = schema;
     this.ownsStream = ownsStream;
     this.options    = options.Clone();
 }
コード例 #16
0
 private FixedLengthReader(TextReader reader, FixedLengthSchema schema, FixedLengthOptions options = null, bool hasSchema = true)
 {
     if (reader == null)
     {
         throw new ArgumentNullException(nameof(reader));
     }
     if (hasSchema && schema == null)
     {
         throw new ArgumentNullException(nameof(schema));
     }
     if (options == null)
     {
         options = new FixedLengthOptions();
     }
     parser        = new FixedLengthRecordParser(reader, schema, options);
     this.metadata = new Metadata()
     {
         Schema  = schema,
         Options = options.Clone()
     };
 }
コード例 #17
0
 /// <summary>
 /// Initializes a new FixedLengthComplexColumn 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 FixedLengthComplexColumn(string columnName, FixedLengthSchema schema, FixedLengthOptions options = null)
     : base(columnName)
 {
     this.schema = schema ?? throw new ArgumentNullException(nameof(schema));
     Options     = options;
 }
コード例 #18
0
 public FixedLengthRecordWriter(TextWriter writer, FixedLengthSchemaInjector injector, FixedLengthOptions options)
     : this(writer, (FixedLengthSchema)null, options)
 {
     this.injector = injector;
 }
コード例 #19
0
 /// <summary>
 /// Initializes a new instance of a FixedLengthBuilder.
 /// </summary>
 /// <param name="fileName">The name of the file to write the output to.</param>
 /// <param name="schema">The schema to use to build the output.</param>
 /// <param name="options">The options used to format the output.</param>
 public FixedLengthWriter(string fileName, FixedLengthSchema schema, FixedLengthOptions options)
     : this(File.OpenWrite(fileName), schema, options, true)
 {
 }
コード例 #20
0
 /// <summary>
 /// Initializes a new instance of a FixedLengthParser.
 /// </summary>
 /// <param name="stream">A stream containing the records to parse.</param>
 /// <param name="schema">The schema object defining which columns are in each record.</param>
 /// <param name="options">An object containing settings for configuring the parser.</param>
 /// <exception cref="System.ArgumentNullException">The stream is null.</exception>
 /// <exception cref="System.ArgumentNullException">The schema is null.</exception>
 /// <exception cref="System.ArgumentNullException">The options is null.</exception>
 public FixedLengthReader(Stream stream, FixedLengthSchema schema, FixedLengthOptions options)
     : this(stream, schema, options, false)
 {
 }
コード例 #21
0
 /// <summary>
 /// Initializes a new instance of a FixedLengthParser.
 /// </summary>
 /// <param name="fileName">The path to the file containing the records to parse.</param>
 /// <param name="schema">The schema object defining which columns are in each record.</param>
 /// <param name="options">An object containing settings for configuring the parser.</param>
 /// <exception cref="System.ArgumentNullException">The schema is null.</exception>
 /// <exception cref="System.ArgumentNullException">The options is null.</exception>
 public FixedLengthReader(string fileName, FixedLengthSchema schema, FixedLengthOptions options)
     : this(File.OpenRead(fileName), schema, options, true)
 {
 }
コード例 #22
0
 public FixedLengthRecordWriter(TextWriter writer, FixedLengthSchema schema, FixedLengthOptions options)
 {
     this.writer  = writer;
     this.schema  = schema;
     this.options = options.Clone();
 }
コード例 #23
0
 /// <summary>
 /// Initializes a new instance of a FixedLengthBuilder.
 /// </summary>
 /// <param name="stream">The stream to write the output to.</param>
 /// <param name="schema">The schema to use to build the output.</param>
 /// <param name="options">The options used to format the output.</param>
 public FixedLengthWriter(Stream stream, FixedLengthSchema schema, FixedLengthOptions options)
     : this(stream, schema, options, false)
 {
 }
コード例 #24
0
 public FixedLengthRecordWriter(TextWriter writer, FixedLengthSchema schema, FixedLengthOptions options)
 {
     this.writer = writer;
     this.schema = schema;
     this.options = options.Clone();
 }
コード例 #25
0
 /// <summary>
 /// Initializes a new FixedLengthReader with the given schema.
 /// </summary>
 /// <param name="reader">A reader over the fixed-length document.</param>
 /// <param name="schemaSelector">The schema selector configured to determine the schema dynamically.</param>
 /// <param name="options">The options controlling how the fixed-length document is read.</param>
 /// <exception cref="ArgumentNullException">The reader is null.</exception>
 /// <exception cref="ArgumentNullException">The schema selector is null.</exception>
 public FixedLengthReader(TextReader reader, FixedLengthSchemaSelector schemaSelector, FixedLengthOptions options = null)
     : this(reader, null, options, false)
 {
     this.schemaSelector = schemaSelector ?? throw new ArgumentNullException(nameof(schemaSelector));
 }
コード例 #26
0
 /// <summary>
 /// Initializes a new FixedLengthReader with the given schema.
 /// </summary>
 /// <param name="reader">A reader over the fixed-length document.</param>
 /// <param name="schema">The schema of the fixed-length document.</param>
 /// <param name="options">The options controlling how the fixed-length document is read.</param>
 /// <exception cref="ArgumentNullException">The reader is null.</exception>
 /// <exception cref="ArgumentNullException">The schema is null.</exception>
 public FixedLengthReader(TextReader reader, FixedLengthSchema schema, FixedLengthOptions options = null)
     : this(reader, schema, options, true)
 {
 }