AxibugEmuOnline/AxibugEmuOnline.Client/Assets/Script/Common/ProtoBufHelper.cs
2024-06-28 18:08:25 +08:00

22 lines
491 B
C#

using Google.Protobuf;
using System;
namespace AxibugEmuOnline.Client.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;
}
}
}