Пример #1
0
    //Protobuffer从MemoryStream进行反序列化
    public bool FromMemoryStream(MemoryStream protoMS)
    {
        FriendFriendDataV1 pb = ProtoBuf.Serializer.Deserialize <FriendFriendDataV1>(protoMS);

        FromPB(pb);
        return(true);
    }
Пример #2
0
 //从Protobuffer类型初始化
 public void FromPB(FriendFriendDataV1 v)
 {
     if (v == null)
     {
         return;
     }
     m_FriendList.Clear();
     for (int i = 0; i < v.FriendList.Count; i++)
     {
         m_FriendList.Add(new FriendFriendObjWraperV1());
     }
     for (int i = 0; i < v.FriendList.Count; i++)
     {
         m_FriendList[i].FromPB(v.FriendList[i]);
     }
     m_BlackList.Clear();
     for (int i = 0; i < v.BlackList.Count; i++)
     {
         m_BlackList.Add(new FriendFriendObjWraperV1());
     }
     for (int i = 0; i < v.BlackList.Count; i++)
     {
         m_BlackList[i].FromPB(v.BlackList[i]);
     }
     m_ContactsList.Clear();
     for (int i = 0; i < v.ContactsList.Count; i++)
     {
         m_ContactsList.Add(new FriendFriendObjWraperV1());
     }
     for (int i = 0; i < v.ContactsList.Count; i++)
     {
         m_ContactsList[i].FromPB(v.ContactsList[i]);
     }
     m_StrangerFriendList.Clear();
     for (int i = 0; i < v.StrangerFriendList.Count; i++)
     {
         m_StrangerFriendList.Add(v.StrangerFriendList[i]);
     }
 }
Пример #3
0
    //转化成Protobuffer类型函数
    public FriendFriendDataV1 ToPB()
    {
        FriendFriendDataV1 v = new FriendFriendDataV1();

        for (int i = 0; i < (int)m_FriendList.Count; i++)
        {
            v.FriendList.Add(m_FriendList[i].ToPB());
        }
        for (int i = 0; i < (int)m_BlackList.Count; i++)
        {
            v.BlackList.Add(m_BlackList[i].ToPB());
        }
        for (int i = 0; i < (int)m_ContactsList.Count; i++)
        {
            v.ContactsList.Add(m_ContactsList[i].ToPB());
        }
        for (int i = 0; i < (int)m_StrangerFriendList.Count; i++)
        {
            v.StrangerFriendList.Add(m_StrangerFriendList[i]);
        }

        return(v);
    }