namespace ASC.Common.Caching; public class ProtobufSerializer : ISerializer where T : IMessage, new() { public byte[] Serialize(T data, SerializationContext context) => data.ToByteArray(); } public class ProtobufDeserializer : IDeserializer where T : IMessage, new() { private readonly MessageParser _parser; public ProtobufDeserializer() => _parser = new MessageParser(() => new T()); public T Deserialize(ReadOnlySpan data, bool isNull, SerializationContext context) => _parser.ParseFrom(data.ToArray()); } public static class GuidExtension { public static ByteString ToByteString(this Guid id) => ByteString.CopyFrom(id.ToByteArray()); public static Guid FromByteString(this ByteString id) => new Guid(id.ToByteArray()); }