/// <summary>
        /// Formats the given object array into an embedded record.
        /// </summary>
        /// <param name="context">Holds information about the column current being processed.</param>
        /// <param name="values">The object array containing the values of the embedded record.</param>
        /// <returns>A formatted string containing the embedded data.</returns>
        protected override string OnFormat(IColumnContext context, object[] values)
        {
            var writer       = new StringWriter();
            var recordWriter = new FixedLengthRecordWriter(writer, schema, Options ?? new FixedLengthOptions());

            recordWriter.WriteRecord(values);
            return(writer.ToString());
        }
Example #2
0
        /// <summary>
        /// Formats the given object array into an embedded record.
        /// </summary>
        /// <param name="value">The object array containing the values of the embedded record.</param>
        /// <returns>A formatted string containing the embedded data.</returns>
        public override string Format(object value)
        {
            object[] values = value as object[];
            if (values == null)
            {
                return(NullHandler.GetNullRepresentation());
            }
            StringWriter            writer       = new StringWriter();
            FixedLengthRecordWriter recordWriter = new FixedLengthRecordWriter(writer, schema, options);

            recordWriter.WriteRecord(values);
            return(writer.ToString());
        }
Example #3
0
        /// <summary>
        /// Formats the given object array into an embedded record.
        /// </summary>
        /// <param name="context">Holds information about the column current being processed.</param>
        /// <param name="value">The object array containing the values of the embedded record.</param>
        /// <returns>A formatted string containing the embedded data.</returns>
        public override string Format(IColumnContext context, object value)
        {
            var values = value as object[];

            if (values == null)
            {
                return(NullHandler.GetNullRepresentation());
            }
            var writer       = new StringWriter();
            var recordWriter = new FixedLengthRecordWriter(writer, schema, Options ?? new FixedLengthOptions());

            recordWriter.WriteRecord(values);
            return(writer.ToString());
        }
Example #4
0
 /// <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);
 }
Example #5
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(nameof(writer));
     }
     if (schema == null)
     {
         throw new ArgumentNullException(nameof(schema));
     }
     if (options == null)
     {
         options = new FixedLengthOptions();
     }
     recordWriter = new FixedLengthRecordWriter(writer, schema, options);
 }
Example #6
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;
 }
 /// <summary>
 /// Formats the given object array into an embedded record.
 /// </summary>
 /// <param name="value">The object array containing the values of the embedded record.</param>
 /// <returns>A formatted string containing the embedded data.</returns>
 public override string Format(object value)
 {
     object[] values = value as object[];
     if (values == null)
     {
         return NullHandler.GetNullRepresentation();
     }
     StringWriter writer = new StringWriter();
     FixedLengthRecordWriter recordWriter = new FixedLengthRecordWriter(writer, schema, options);
     recordWriter.WriteRecord(values);
     return writer.ToString();
 }