ProtobufPacker.cs 614 B

12345678910111213141516171819202122232425262728
  1. using System;
  2. using System.IO;
  3. namespace ETModel
  4. {
  5. public class ProtobufPacker : IMessagePacker
  6. {
  7. public byte[] SerializeToByteArray(object obj)
  8. {
  9. return ProtobufHelper.ToBytes(obj);
  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. public object DeserializeFrom(object instance, MemoryStream stream)
  20. {
  21. return ProtobufHelper.FromStream(instance, stream);
  22. }
  23. }
  24. }