using System; using System.IO; namespace ETModel { public class ProtobufPacker : IMessagePacker { public byte[] SerializeToByteArray(object obj) { return ProtobufHelper.ToBytes(obj); } public string SerializeToText(object obj) { return JsonHelper.ToJson(obj); } public object DeserializeFrom(Type type, byte[] bytes) { return ProtobufHelper.FromBytes(type, bytes); } public object DeserializeFrom(Type type, Stream stream) { return ProtobufHelper.FromStream(type, stream); } public object DeserializeFrom(Type type, byte[] bytes, int index, int count) { return ProtobufHelper.FromBytes(type, bytes, index, count); } public T DeserializeFrom(byte[] bytes) { return ProtobufHelper.FromBytes(bytes); } public T DeserializeFrom(byte[] bytes, int index, int count) { return ProtobufHelper.FromBytes(bytes, index, count); } public T DeserializeFrom(string str) { return JsonHelper.FromJson(str); } public object DeserializeFrom(Type type, string str) { return JsonHelper.FromJson(type, str); } } }