using ProtoBuf; namespace EonaCat.gRPC.Proto.Helpers; public static class Utility { public static byte[] ProtoSerialize(T record) where T : class { if (null == record) return null; try { using (var stream = new MemoryStream()) { Serializer.Serialize(stream, record); return stream.ToArray(); } } catch { // Log error throw; } } public static T ProtoDeserialize(byte[] data) where T : class { if (null == data) return null; try { using (var stream = new MemoryStream(data)) { return Serializer.Deserialize(stream); } } catch { // Log error throw; } } }