From 00f7ecfd1a06b01940c15f33ecb897206a828abb Mon Sep 17 00:00:00 2001 From: Allan Ritchie Date: Sat, 19 Oct 2024 13:53:20 -0400 Subject: [PATCH] JsonSerializerOptions gets defaulted --- .../Infrastructure/SerializerService.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Shiny.Mediator/Infrastructure/SerializerService.cs b/src/Shiny.Mediator/Infrastructure/SerializerService.cs index bf4be39..f7575f2 100644 --- a/src/Shiny.Mediator/Infrastructure/SerializerService.cs +++ b/src/Shiny.Mediator/Infrastructure/SerializerService.cs @@ -11,11 +11,9 @@ public interface ISerializerService public class SerializerService : ISerializerService { - readonly JsonSerializerOptions jsonOptions; - - public SerializerService(JsonSerializerOptions? options = null) + public SerializerService() { - this.jsonOptions = options ?? new JsonSerializerOptions + this.JsonOptions = new JsonSerializerOptions { Converters = { @@ -24,15 +22,18 @@ public SerializerService(JsonSerializerOptions? options = null) }; } + + public JsonSerializerOptions JsonOptions { get; set; } + public string Serialize(T obj) { - var json = JsonSerializer.Serialize(obj, this.jsonOptions); + var json = JsonSerializer.Serialize(obj, this.JsonOptions); return json; } public T Deserialize(string json) { - var obj = JsonSerializer.Deserialize(json, this.jsonOptions)!; + var obj = JsonSerializer.Deserialize(json, this.JsonOptions)!; return obj; } } \ No newline at end of file