using System; namespace Model { public class MongoPacker: IMessagePacker { public byte[] SerializeToByteArray(object obj) { return MongoHelper.ToBson(obj); } public string SerializeToText(object obj) { return MongoHelper.ToJson(obj); } public object DeserializeFrom(Type type, byte[] bytes) { return MongoHelper.FromBson(type, bytes); } public object DeserializeFrom(Type type, byte[] bytes, int index, int count) { return MongoHelper.FromBson(type, bytes, index, count); } public T DeserializeFrom(byte[] bytes) { return MongoHelper.FromBson(bytes); } public T DeserializeFrom(byte[] bytes, int index, int count) { return MongoHelper.FromBson(bytes, index, count); } public T DeserializeFrom(string str) { return MongoHelper.FromJson(str); } public object DeserializeFrom(Type type, string str) { return MongoHelper.FromJson(type, str); } } }