Пример #1
0
    /// <summary>
    /// 读取字节流(完整版)
    /// </summary>
    protected override void toReadBytesFull(BytesReadStream stream)
    {
        stream.startReadObj();

        int friendsLen = stream.readLen();

        if (this.friends != null)
        {
            this.friends.clear();
            this.friends.ensureCapacity(friendsLen);
        }
        else
        {
            this.friends = new LongObjectMap <FriendData>(friendsLen);
        }

        LongObjectMap <FriendData> friendsT = this.friends;

        for (int friendsI = friendsLen - 1; friendsI >= 0; --friendsI)
        {
            FriendData friendsV;
            BaseData   friendsVT = stream.readDataFullNotNull();
            if (friendsVT != null)
            {
                if (friendsVT is FriendData)
                {
                    friendsV = (FriendData)friendsVT;
                }
                else
                {
                    friendsV = new FriendData();
                    if (!(friendsVT.GetType().IsAssignableFrom(typeof(FriendData))))
                    {
                        stream.throwTypeReadError(typeof(FriendData), friendsVT.GetType());
                    }
                    friendsV.shadowCopy(friendsVT);
                }
            }
            else
            {
                friendsV = null;
            }

            friendsT.put(friendsV.playerID, friendsV);
        }

        int blackListLen = stream.readLen();

        if (this.blackList != null)
        {
            this.blackList.clear();
            this.blackList.ensureCapacity(blackListLen);
        }
        else
        {
            this.blackList = new LongObjectMap <ContactData>(blackListLen);
        }

        LongObjectMap <ContactData> blackListT = this.blackList;

        for (int blackListI = blackListLen - 1; blackListI >= 0; --blackListI)
        {
            ContactData blackListV;
            BaseData    blackListVT = stream.readDataFullNotNull();
            if (blackListVT != null)
            {
                if (blackListVT is ContactData)
                {
                    blackListV = (ContactData)blackListVT;
                }
                else
                {
                    blackListV = new ContactData();
                    if (!(blackListVT.GetType().IsAssignableFrom(typeof(ContactData))))
                    {
                        stream.throwTypeReadError(typeof(ContactData), blackListVT.GetType());
                    }
                    blackListV.shadowCopy(blackListVT);
                }
            }
            else
            {
                blackListV = null;
            }

            blackListT.put(blackListV.playerID, blackListV);
        }

        int applyDicLen = stream.readLen();

        if (this.applyDic != null)
        {
            this.applyDic.clear();
            this.applyDic.ensureCapacity(applyDicLen);
        }
        else
        {
            this.applyDic = new LongObjectMap <ApplyAddFriendData>(applyDicLen);
        }

        LongObjectMap <ApplyAddFriendData> applyDicT = this.applyDic;

        for (int applyDicI = applyDicLen - 1; applyDicI >= 0; --applyDicI)
        {
            ApplyAddFriendData applyDicV;
            BaseData           applyDicVT = stream.readDataFullNotNull();
            if (applyDicVT != null)
            {
                if (applyDicVT is ApplyAddFriendData)
                {
                    applyDicV = (ApplyAddFriendData)applyDicVT;
                }
                else
                {
                    applyDicV = new ApplyAddFriendData();
                    if (!(applyDicVT.GetType().IsAssignableFrom(typeof(ApplyAddFriendData))))
                    {
                        stream.throwTypeReadError(typeof(ApplyAddFriendData), applyDicVT.GetType());
                    }
                    applyDicV.shadowCopy(applyDicVT);
                }
            }
            else
            {
                applyDicV = null;
            }

            applyDicT.put(applyDicV.playerID, applyDicV);
        }

        stream.endReadObj();
    }