2026-11-10 09:23:35 +01:00
|
|
|
using PipeMethodCalls;
|
2026-11-10 09:31:18 +01:00
|
|
|
using System.Text.Json;
|
2026-11-10 09:23:35 +01:00
|
|
|
|
2026-11-10 09:31:18 +01:00
|
|
|
namespace ClientServerShared;
|
2026-11-10 09:23:35 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// JSON serializer that also includes public fields (required for System.Numerics.Vector3).
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class JsonFieldsPipeSerializer : IPipeSerializer
|
|
|
|
|
{
|
|
|
|
|
private static readonly JsonSerializerOptions Options = new() { IncludeFields = true };
|
|
|
|
|
|
|
|
|
|
public object Deserialize(byte[] data, Type type) => JsonSerializer.Deserialize(data, type, Options)!;
|
|
|
|
|
|
|
|
|
|
public byte[] Serialize(object o) => JsonSerializer.SerializeToUtf8Bytes(o, Options);
|
|
|
|
|
}
|