FormatValues() private method

Formats the given values assuming that they are in the same order as the column definitions.
private FormatValues ( object values ) : string[]
values object The values to format.
return string[]
Exemplo n.º 1
0
        public void WriteRecord(object[] values)
        {
            if (values.Length != schema.ColumnDefinitions.HandledCount)
            {
                throw new ArgumentException(SharedResources.WrongNumberOfValues, "values");
            }
            var formattedColumns = schema.FormatValues(values);
            var fittedColumns    = formattedColumns.Select((v, i) => fitWidth(schema.Windows[i], v));

            foreach (string column in fittedColumns)
            {
                writer.Write(column);
            }
        }
Exemplo n.º 2
0
        private string[] formatValues(object[] values, FixedLengthSchema schema)
        {
            var metadata = injector == null ? Metadata : new FixedLengthWriterMetadata()
            {
                Schema             = schema,
                Options            = Metadata.Options,
                RecordCount        = Metadata.RecordCount,
                LogicalRecordCount = Metadata.LogicalRecordCount
            };

            return(schema.FormatValues(metadata, values));
        }
Exemplo n.º 3
0
 /// <summary>
 /// Writes the textual representation of the given values to the writer.
 /// </summary>
 /// <param name="values">The values to write.</param>
 /// <exception cref="System.ArgumentNullException">The values array is null.</exception>
 public void Write(object[] values)
 {
     if (isDisposed)
     {
         throw new ObjectDisposedException("FixedLengthWriter");
     }
     if (values == null)
     {
         throw new ArgumentNullException("values");
     }
     if (values.Length != schema.ColumnDefinitions.Count)
     {
         throw new ArgumentException(Resources.WrongNumberOfValues, "values");
     }
     foreach (string column in schema.FormatValues(values).Select((v, i) => fitWidth(i, v)))
     {
         writer.Write(column);
     }
     writer.Write(options.RecordSeparator);
 }