AxibugEmuOnline/AxibugEmuOnline.Server/Common/ProtoBufHelper.cs

23 lines
479 B
C#
Raw Normal View History

2024-06-28 17:43:55 +08:00
using Google.Protobuf;
namespace AxibugEmuOnline.Server.Common
{
public static class ProtoBufHelper
{
public static byte[] Serizlize(IMessage msg)
{
return msg.ToByteArray();
}
public static T DeSerizlize<T>(byte[] bytes)
{
var msgType = typeof(T);
object msg = Activator.CreateInstance(msgType);
((IMessage)msg).MergeFrom(bytes);
return (T)msg;
}
}
}