///<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);
public void LoadData(byte[] data, ref int offset) { string useField = "t_" + Settings.Ins.Language; t_id = XBuffer.ReadInt(data, ref offset); if (string.IsNullOrEmpty(t_content) && useField == "t_chinese") { t_content = XBuffer.ReadString(data, ref offset); } else { //不需要的语言字段跳过 short slen = XBuffer.ReadShort(data, ref offset); offset += slen; } if (string.IsNullOrEmpty(t_content) && useField == "t_chinesetraditional") { t_content = XBuffer.ReadString(data, ref offset); } else { //不需要的语言字段跳过 short slen = XBuffer.ReadShort(data, ref offset); offset += slen; } if (string.IsNullOrEmpty(t_content) && useField == "t_english") { t_content = XBuffer.ReadString(data, ref offset); } else { //不需要的语言字段跳过 short slen = XBuffer.ReadShort(data, ref offset); offset += slen; } }
///<summary>反序列化,读取数据</summary> public override int Read(byte[] _buffer_, int _offset_) { _offset_ = base.Read(_buffer_, _offset_); //字段个数,最多支持255个 var _fieldNum_ = XBuffer.ReadByte(_buffer_, ref _offset_); do { if (_fieldNum_ > 0) { msg = XBuffer.ReadString(_buffer_, ref _offset_); } else { break; } if (_fieldNum_ > 1) { msgLanId = XBuffer.ReadInt(_buffer_, ref _offset_); } else { break; } if (_fieldNum_ > 2) { type = XBuffer.ReadShort(_buffer_, ref _offset_); } else { break; } }while(false); return(_offset_); }
///<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_); }