//Protobuffer从MemoryStream进行反序列化 public bool FromMemoryStream(MemoryStream protoMS) { BaseAttrUserDataV1 pb = ProtoBuf.Serializer.Deserialize <BaseAttrUserDataV1>(protoMS); FromPB(pb); return(true); }
//转化成Protobuffer类型函数 public BaseAttrUserDataV1 ToPB() { BaseAttrUserDataV1 v = new BaseAttrUserDataV1(); v.HeadID = m_HeadID; v.Exp = m_Exp; v.CreateTime = m_CreateTime; v.LastLoginTime = m_LastLoginTime; v.Last2LoginDate = m_Last2LoginDate; v.LastLogoutTime = m_LastLogoutTime; v.Money = m_Money; v.Diamond = m_Diamond; v.GMDiamond = m_GMDiamond; v.Strength = m_Strength; v.Feats = m_Feats; v.GotRankRewardTime = m_GotRankRewardTime; v.MaxMilitary = m_MaxMilitary; for (int i = 0; i < (int)m_MasterAttrs.Count; i++) { v.MasterAttrs.Add(m_MasterAttrs[i]); } v.CurMilitary = m_CurMilitary; return(v); }
//从Protobuffer类型初始化 public void FromPB(BaseAttrUserDataV1 v) { if (v == null) { return; } m_Exp = v.Exp; m_Level = v.Level; m_ServerTime = v.ServerTime; m_RoleId = v.RoleId; }
//转化成Protobuffer类型函数 public BaseAttrUserDataV1 ToPB() { BaseAttrUserDataV1 v = new BaseAttrUserDataV1(); v.Exp = m_Exp; v.Level = m_Level; v.ServerTime = m_ServerTime; v.RoleId = m_RoleId; return(v); }
//从Protobuffer类型初始化 public void FromPB(BaseAttrUserDataV1 v) { m_HeadID = v.HeadID; m_Exp = v.Exp; m_CreateTime = v.CreateTime; m_LastLoginTime = v.LastLoginTime; m_Last2LoginDate = v.Last2LoginDate; m_LastLogoutTime = v.LastLogoutTime; m_Money = v.Money; m_Diamond = v.Diamond; m_GMDiamond = v.GMDiamond; m_Strength = v.Strength; m_Feats = v.Feats; m_GotRankRewardTime = v.GotRankRewardTime; m_MaxMilitary = v.MaxMilitary; m_MasterAttrs.Clear(); for (int i = 0; i < v.MasterAttrs.Count; i++) { m_MasterAttrs.Add(v.MasterAttrs[i]); } m_CurMilitary = v.CurMilitary; }