/// <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(); SeparatedValueRecordWriter recordWriter = new SeparatedValueRecordWriter(writer, schema, options); recordWriter.WriteRecord(values); return(writer.ToString()); }
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); }
/// <summary> /// Initializes a new SeparatedValueWriter with the given schema. /// </summary> /// <param name="writer">A writer over the separated value 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 SeparatedValueWriter(TextWriter writer, SeparatedValueSchemaInjector injector, SeparatedValueOptions options = null) { if (writer == null) { throw new ArgumentNullException(nameof(writer)); } if (injector == null) { throw new ArgumentNullException(nameof(injector)); } if (options == null) { options = new SeparatedValueOptions(); } recordWriter = new SeparatedValueRecordWriter(writer, injector, options); }