| | | 1 | | using ArturRios.Data.Export.Configuration; |
| | | 2 | | using MessagePack; |
| | | 3 | | |
| | | 4 | | namespace ArturRios.Data.Export.Exporters; |
| | | 5 | | |
| | | 6 | | /// <summary>Serializes the collection to MessagePack (the binary format) using the contractless resolver.</summary> |
| | | 7 | | /// <typeparam name="T">The record type.</typeparam> |
| | | 8 | | /// <param name="options">MessagePack options.</param> |
| | 4 | 9 | | public class MessagePackExporter<T>(MessagePackOptions options) : ExporterBase<T> where T : class |
| | | 10 | | { |
| | | 11 | | /// <inheritdoc /> |
| | | 12 | | protected override Task WriteCoreAsync(IEnumerable<T> data, Stream destination, CancellationToken ct) |
| | 2 | 13 | | { |
| | 2 | 14 | | var array = data as T[] ?? data.ToArray(); |
| | 2 | 15 | | return MessagePackSerializer.SerializeAsync(destination, array, options.Effective, ct); |
| | 2 | 16 | | } |
| | | 17 | | } |