internal static string ToText(object rec, ChoJSONRecordConfiguration configuration, Encoding encoding, int bufferSize, TraceSwitch traceSwitch = null) { ChoJSONRecordWriter writer = new ChoJSONRecordWriter(rec.GetType(), configuration); writer.TraceSwitch = traceSwitch == null ? ChoETLFramework.TraceSwitchOff : traceSwitch; using (var stream = new MemoryStream()) using (var reader = new StreamReader(stream)) using (var sw = new StreamWriter(stream, configuration.Encoding, configuration.BufferSize)) { writer.WriteTo(sw, new object[] { rec }).Loop(); sw.Flush(); stream.Position = 0; return(reader.ReadToEnd()); } }
public void Write(IEnumerable <T> records) { _writer.Writer = this; _writer.TraceSwitch = TraceSwitch; _writer.WriteTo(_textWriter.Value, records.OfType <object>()).Loop(); }
public void Write(IEnumerable <T> records) { _writer.Writer = this; _writer.TraceSwitch = TraceSwitch; _writer.WriteTo(_textWriter, records).Loop(); }