/ Framework / Core / SerializeGate.cs
SerializeGate.cs
 1  using Newtonsoft.Json;
 2  
 3  namespace Core
 4  {
 5      public static class SerializeGate
 6      {
 7          /// <summary>
 8          /// SerializeGate was added to help ensure deployment objects are serializable and remain viable after deserialization.
 9          /// Tools can be built on top of the core interface that rely on deployment objects being serializable.
10          /// Insert the serialization gate after deployment but before wrapping to ensure any future changes don't break this requirement.
11          /// </summary>
12          public static T Gate<T>(T anything)
13          {
14              var json = JsonConvert.SerializeObject(anything);
15              return JsonConvert.DeserializeObject<T>(json)!;
16          }
17      }
18  }