ProtobufHelper.cs 252 B

123456789101112131415
  1. using System.IO;
  2. using ProtoBuf;
  3. namespace Helper
  4. {
  5. public static class ProtobufHelper
  6. {
  7. public static byte[] ProtoToBytes<T>(T message)
  8. {
  9. var ms = new MemoryStream();
  10. Serializer.Serialize(ms, message);
  11. return ms.ToArray();
  12. }
  13. }
  14. }