29 lines
581 B
C#
29 lines
581 B
C#
|
using Google.Protobuf;
|
||
|
using System;
|
||
|
public class ProtoBufffer
|
||
|
{
|
||
|
public static byte[] Serialize(IMessage message)
|
||
|
{
|
||
|
return message.ToByteArray();
|
||
|
}
|
||
|
|
||
|
public static T DeSerialize<T>(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<T>(ByteString data)
|
||
|
{
|
||
|
throw new NotImplementedException();
|
||
|
}
|
||
|
}
|
||
|
|