| | | 1 | | using System.Text; |
| | | 2 | | using System.Text.Json; |
| | | 3 | | using MessagePack; |
| | | 4 | | using MessagePack.Resolvers; |
| | | 5 | | |
| | | 6 | | namespace ArturRios.Data.Export.Configuration; |
| | | 7 | | |
| | | 8 | | /// <summary>Options for the CSV exporter.</summary> |
| | | 9 | | public class CsvOptions |
| | | 10 | | { |
| | | 11 | | /// <summary>Field delimiter. Default ','.</summary> |
| | | 12 | | public char Delimiter { get; set; } = ','; |
| | | 13 | | |
| | | 14 | | /// <summary>Whether to write a header row from the column map. Default true.</summary> |
| | | 15 | | public bool IncludeHeader { get; set; } = true; |
| | | 16 | | |
| | | 17 | | /// <summary>Text encoding. Default UTF-8 without BOM.</summary> |
| | | 18 | | public Encoding Encoding { get; set; } = new UTF8Encoding(false); |
| | | 19 | | } |
| | | 20 | | |
| | | 21 | | /// <summary>Options for the JSON exporter.</summary> |
| | | 22 | | public class JsonOptions |
| | | 23 | | { |
| | | 24 | | /// <summary>Whether to indent the JSON. Ignored when <see cref="SerializerOptions" /> is set.</summary> |
| | | 25 | | public bool WriteIndented { get; set; } |
| | | 26 | | |
| | | 27 | | /// <summary>Explicit serializer options; when set, used as-is.</summary> |
| | | 28 | | public JsonSerializerOptions? SerializerOptions { get; set; } |
| | | 29 | | } |
| | | 30 | | |
| | | 31 | | /// <summary>Options for the TXT exporter.</summary> |
| | | 32 | | public class TxtOptions |
| | | 33 | | { |
| | | 34 | | /// <summary>Text encoding. Default UTF-8 without BOM.</summary> |
| | 17 | 35 | | public Encoding Encoding { get; set; } = new UTF8Encoding(false); |
| | | 36 | | |
| | | 37 | | /// <summary>Line terminator. Default <see cref="Environment.NewLine" />.</summary> |
| | 20 | 38 | | public string NewLine { get; set; } = Environment.NewLine; |
| | | 39 | | } |
| | | 40 | | |
| | | 41 | | /// <summary>Options for the MessagePack exporter.</summary> |
| | | 42 | | public class MessagePackOptions |
| | | 43 | | { |
| | | 44 | | /// <summary>Explicit serializer options; when set, used as-is.</summary> |
| | | 45 | | public MessagePackSerializerOptions? SerializerOptions { get; set; } |
| | | 46 | | |
| | | 47 | | /// <summary>The options actually used: caller-supplied, else contractless standard (no attributes required).</summa |
| | | 48 | | public MessagePackSerializerOptions Effective => |
| | | 49 | | SerializerOptions ?? MessagePackSerializerOptions.Standard.WithResolver(ContractlessStandardResolver.Instance); |
| | | 50 | | } |
| | | 51 | | |
| | | 52 | | /// <summary>Aggregate options for the core exporters, configured via <c>AddExport</c>.</summary> |
| | | 53 | | public class ExportOptions |
| | | 54 | | { |
| | | 55 | | /// <summary>CSV options.</summary> |
| | | 56 | | public CsvOptions Csv { get; set; } = new(); |
| | | 57 | | |
| | | 58 | | /// <summary>JSON options.</summary> |
| | | 59 | | public JsonOptions Json { get; set; } = new(); |
| | | 60 | | |
| | | 61 | | /// <summary>TXT options.</summary> |
| | | 62 | | public TxtOptions Txt { get; set; } = new(); |
| | | 63 | | |
| | | 64 | | /// <summary>MessagePack options.</summary> |
| | | 65 | | public MessagePackOptions MessagePack { get; set; } = new(); |
| | | 66 | | } |