ProtobufPacker.cs 487 B

1234567891011121314151617181920212223
  1. using System;
  2. using System.IO;
  3. namespace ET
  4. {
  5. public class ProtobufPacker : IMessagePacker
  6. {
  7. public void SerializeTo(object obj, MemoryStream stream)
  8. {
  9. ProtobufHelper.ToStream(obj, stream);
  10. }
  11. public object DeserializeFrom(Type type, byte[] bytes, int index, int count)
  12. {
  13. return ProtobufHelper.FromBytes(type, bytes, index, count);
  14. }
  15. public object DeserializeFrom(Type type, MemoryStream stream)
  16. {
  17. return ProtobufHelper.FromStream(type, stream);
  18. }
  19. }
  20. }