2023-09-20 07:16:57 +00:00
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
|
|
|
|
namespace Core
|
|
|
|
|
{
|
|
|
|
|
public static class SerializeGate
|
|
|
|
|
{
|
2023-09-20 08:13:29 +00:00
|
|
|
|
/// <summary>
|
2023-10-19 09:18:59 +00:00
|
|
|
|
/// SerializeGate was added to help ensure deployment objects are serializable and remain viable after deserialization.
|
2023-09-20 08:13:29 +00:00
|
|
|
|
/// Tools can be built on top of the core interface that rely on deployment objects being serializable.
|
2023-10-19 09:18:59 +00:00
|
|
|
|
/// Insert the serialization gate after deployment but before wrapping to ensure any future changes don't break this requirement.
|
2023-09-20 08:13:29 +00:00
|
|
|
|
/// </summary>
|
2023-09-20 07:16:57 +00:00
|
|
|
|
public static T Gate<T>(T anything)
|
|
|
|
|
{
|
|
|
|
|
var json = JsonConvert.SerializeObject(anything);
|
|
|
|
|
return JsonConvert.DeserializeObject<T>(json)!;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|