MongoPacker.cs 465 B

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