public void Load(IProtocolBuffer buffer) { byte[] data = buffer.Read(2); Count = BitConverter.ToUInt16(data, 0); Count = BufferUtils.SwapUInt16(Count); data = buffer.Read(2); Index = BitConverter.ToUInt16(data, 0); Index = BufferUtils.SwapUInt16(Count); }
public override object Read(IProtocolBuffer buffer) { byte data = buffer.Read(); IBitCustomType result = (IBitCustomType)Activator.CreateInstance(mType); result.Load(data); return(result); }
public void Read(IProtocolBuffer buffer) { //byte crc = Core.GetCRC(buffer.Array, 1, buffer.Length - 3); //CRC = buffer.Array[buffer.Length - 2]; //if(CRC != crc) // throw new ProtocolProcessError("message check CRC error!"); buffer.Read(); //read start 标识位 ID = buffer.ReadUInt16(); //read id 消息 ID Property.Read(buffer); //read property 消息体属性 SIM = buffer.ReadBCD(6); //read sim 终端手机号 No = buffer.ReadUInt16(); //read no 消息流水号 if (Property.IsPacket) //read packet 消息包封装项 { Packet = new PacketInfo(); Packet.Load(buffer); } if (Property.BodyLength > 0) //read body 消息体 { IProtocolBuffer bodybuffer = ProtocolBufferPool.Default.Pop(); try { buffer.ReadSubBuffer(bodybuffer, Property.BodyLength); Serializer serializer = SerializerFactory.Defalut.Get(ID); if (serializer != null) { Body = serializer.CreateObject(); serializer.Deserialize(Body, bodybuffer); } } finally { ProtocolBufferPool.Default.Push(bodybuffer); } } CRC = buffer.Read(); //read crc 检验码 buffer.Read(); //read end 标识位 }
public void Load(IProtocolBuffer buffer) { byte crc = Core.GetCRC(buffer.Array, 1, buffer.Length - 3); this.CRC = buffer.Array[buffer.Length - 2]; if (this.CRC != crc) { throw new ProtocolProcessError("message check CRC error!"); } buffer.Read(); //read start ID = buffer.ReadUInt16(); //read id Property.Load(buffer); //read property SIM = buffer.ReadBCD(6); //read sim BussinessNO = buffer.ReadUInt16(); //read no if (Property.IsPacket) //read packet { Packet = new PacketInfo(); Packet.Load(buffer); } if (Property.BodyLength > 0) //read body { IProtocolBuffer bodybuffer = ProtocolBufferPool.Default.Pop(); try { buffer.ReadSubBuffer(bodybuffer, Property.BodyLength); Serializer serializer = SerializerFactory.Defalut.Get(ID); Body = serializer.CreateObject(); serializer.Deserialize(Body, bodybuffer); } finally { ProtocolBufferPool.Default.Push(bodybuffer); } } this.CRC = buffer.Read(); //read crc buffer.Read(); //read end }
public override object Read(IProtocolBuffer buffer) { return(buffer.Read(Length)); }