/// <summary> /// 设置消息数据 /// </summary> /// <param name="model">消息model</param> public void SetData(object model) { this.Data = SerializerUtils.Serialize(model); }
/// <summary> /// 序列化消息 /// </summary> /// <returns></returns> public byte[] Serialize() { return(SerializerUtils.Serialize(this)); }
/// <summary> /// 获取消息数据 /// </summary> /// <param name="type">消息model type</param> /// <returns>消息model</returns> public object GetData(Type type) { return(SerializerUtils.Deserialize(type, this.Data)); }
/// <summary> /// 反序列化消息 /// </summary> /// <param name="buffer"></param> /// <returns></returns> public static MsgData Deserialize(byte[] buffer) { return(SerializerUtils.Deserialize <MsgData>(buffer)); }
/// <summary> /// 获取消息数据 /// </summary> /// <typeparam name="T"></typeparam> /// <returns></returns> public T GetData <T>() { return(SerializerUtils.Deserialize <T>(this.Data)); }