using Google.Protobuf; using System; public class ProtoBufffer { public static byte[] Serialize(IMessage message) { return message.ToByteArray(); } public static T DeSerialize(byte[] packet) where T : IMessage, new() { IMessage message = new T(); try { return (T)message.Descriptor.Parser.ParseFrom(packet); } catch (System.Exception e) { throw; } } internal static T DeSerialize(ByteString data) { throw new NotImplementedException(); } }