예제 #1
0
        ///<summary>反序列化,读取数据</summary>
        public override int Read(byte[] _buffer_, int _offset_)
        {
            _offset_ = base.Read(_buffer_, _offset_);
            int _startOffset_  = _offset_;
            int _toReadLength_ = XBuffer.ReadInt(_buffer_, ref _offset_);

            //字段个数,最多支持255个
            var _fieldNum_ = XBuffer.ReadByte(_buffer_, ref _offset_);

            do
            {
                if (_fieldNum_ > 0)
                {
                    l1 = XBuffer.ReadLong(_buffer_, ref _offset_);
                }
                else
                {
                    break;
                }
                if (_fieldNum_ > 1)
                {
                    short _count_ = XBuffer.ReadShort(_buffer_, ref _offset_);
                    for (int _a_ = 0; _a_ < _count_; ++_a_)
                    {
                        l2.Add(XBuffer.ReadString(_buffer_, ref _offset_));
                    }
                }
                else
                {
                    break;
                }
                if (_fieldNum_ > 2)
                {
                    short _count_ = XBuffer.ReadShort(_buffer_, ref _offset_);
                    for (int _a_ = 0; _a_ < _count_; ++_a_)
                    {
                        l3.Add(XBuffer.ReadFloat(_buffer_, ref _offset_));
                    }
                }
                else
                {
                    break;
                }
                if (_fieldNum_ > 3)
                {
                    short _count_ = XBuffer.ReadShort(_buffer_, ref _offset_);
                    for (int _a_ = 0; _a_ < _count_; ++_a_)
                    {
                        var _idx_ = XBuffer.ReadByte(_buffer_, ref _offset_);
                        if (_idx_ <= 0)
                        {
                            l4.Add(default);
예제 #2
0
        ///<summary>反序列化,读取数据</summary>
        public override int Read(byte[] _buffer_, int _offset_)
        {
            _offset_ = base.Read(_buffer_, _offset_);
            int _startOffset_  = _offset_;
            int _toReadLength_ = XBuffer.ReadInt(_buffer_, ref _offset_);

            //字段个数,最多支持255个
            var _fieldNum_ = XBuffer.ReadByte(_buffer_, ref _offset_);

            do
            {
                if (_fieldNum_ > 0)
                {
                    id_f = XBuffer.ReadLong(_buffer_, ref _offset_);
                }
                else
                {
                    break;
                }
                if (_fieldNum_ > 1)
                {
                    s1 = XBuffer.ReadString(_buffer_, ref _offset_);
                }
                else
                {
                    break;
                }
                if (_fieldNum_ > 2)
                {
                    i1 = XBuffer.ReadInt(_buffer_, ref _offset_);
                }
                else
                {
                    break;
                }
                if (_fieldNum_ > 3)
                {
                    b1 = XBuffer.ReadBool(_buffer_, ref _offset_);
                }
                else
                {
                    break;
                }
                if (_fieldNum_ > 4)
                {
                    f1 = XBuffer.ReadFloat(_buffer_, ref _offset_);
                }
                else
                {
                    break;
                }
                if (_fieldNum_ > 5)
                {
                    s2 = XBuffer.ReadShort(_buffer_, ref _offset_);
                }
                else
                {
                    break;
                }
                if (_fieldNum_ > 6)
                {
                    d1 = XBuffer.ReadDouble(_buffer_, ref _offset_);
                }
                else
                {
                    break;
                }
                if (_fieldNum_ > 7)
                {
                    b2 = XBuffer.ReadBytes(_buffer_, ref _offset_);
                }
                else
                {
                    break;
                }
                if (_fieldNum_ > 8)
                {
                    o1 = XBuffer.ReadString(_buffer_, ref _offset_);
                }
                else
                {
                    break;
                }
            }while(false);

            //剔除多余数据
            if (_offset_ < _toReadLength_ - _startOffset_)
            {
                _offset_ += _toReadLength_ - _startOffset_;
            }
            return(_offset_);
        }