| | | 1 | | namespace Nabs.Serialisation; |
| | | 2 | | |
| | | 3 | | public class GlobalSettings |
| | | 4 | | { |
| | | 5 | | private static CsvConfiguration? _csvConfiguration; |
| | | 6 | | private static JsonSerializerOptions? _jsonSerializerOptions; |
| | | 7 | | |
| | | 8 | | public static CsvConfiguration CsvConfiguration |
| | | 9 | | { |
| | | 10 | | get |
| | | 11 | | { |
| | 2 | 12 | | _csvConfiguration ??= new CsvConfiguration(CultureInfo.InvariantCulture) |
| | 2 | 13 | | { |
| | 2 | 14 | | HasHeaderRecord = true, |
| | 2 | 15 | | HeaderValidated = null, |
| | 2 | 16 | | MissingFieldFound = null, |
| | 2 | 17 | | IgnoreBlankLines = true, |
| | 2 | 18 | | Delimiter = ",", |
| | 2 | 19 | | TrimOptions = TrimOptions.Trim |
| | 2 | 20 | | }; |
| | | 21 | | |
| | 2 | 22 | | return _csvConfiguration; |
| | | 23 | | } |
| | | 24 | | } |
| | | 25 | | public static JsonSerializerOptions JsonSerializerOptions |
| | | 26 | | { |
| | | 27 | | get |
| | | 28 | | { |
| | 5 | 29 | | _jsonSerializerOptions ??= new JsonSerializerOptions |
| | 5 | 30 | | { |
| | 5 | 31 | | PropertyNamingPolicy = JsonNamingPolicy.CamelCase, |
| | 5 | 32 | | WriteIndented = true |
| | 5 | 33 | | }; |
| | | 34 | | |
| | 5 | 35 | | return _jsonSerializerOptions; |
| | | 36 | | } |
| | | 37 | | } |
| | | 38 | | |
| | | 39 | | public static void RegisterCsvConfiguration(CsvConfiguration csvConfiguration) |
| | | 40 | | { |
| | 2 | 41 | | _csvConfiguration = csvConfiguration; |
| | 2 | 42 | | } |
| | | 43 | | |
| | | 44 | | public static void RegisterJsonSerializerOptions(JsonSerializerOptions jsonSerializerOptions) |
| | | 45 | | { |
| | 1 | 46 | | _jsonSerializerOptions = jsonSerializerOptions; |
| | 1 | 47 | | } |
| | | 48 | | } |