ProtobufPacker.cs 775 B

123456789101112131415161718192021222324252627282930313233
  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(object instance, byte[] bytes, int index, int count)
  16. {
  17. return ProtobufHelper.FromBytes(instance, bytes, index, count);
  18. }
  19. public object DeserializeFrom(Type type, MemoryStream stream)
  20. {
  21. return ProtobufHelper.FromStream(type, stream);
  22. }
  23. public object DeserializeFrom(object instance, MemoryStream stream)
  24. {
  25. return ProtobufHelper.FromStream(instance, stream);
  26. }
  27. }
  28. }