public static bool Decode(byte[] packetData, ref PKTArrayTest1 packet) { int readPos = 0; packet.Count = BitConverter.ToInt16(packetData, readPos); readPos += 2; PacketEnDecodeUtil.ToCollection(packetData, ref readPos, packet.Count, packet.ValueList); return(true); }
public void TestMethod_PKTArrayTest1EnDecode() { var reqPacket = new PKTArrayTest1(); reqPacket.Count = 3; reqPacket.ValueList.AddRange(new int[] { 4,7,2}); var packetData = new List<byte>(); PKTArrayTest1EnDecode.Encode(packetData, reqPacket); var reqPacket2 = new PKTArrayTest1(); PKTArrayTest1EnDecode.Decode(packetData.ToArray(), ref reqPacket2); Assert.AreEqual(reqPacket.Count, reqPacket2.Count); Assert.AreEqual(reqPacket.ValueList[0], reqPacket2.ValueList[0]); Assert.AreEqual(reqPacket.ValueList[1], reqPacket2.ValueList[1]); Assert.AreEqual(reqPacket.ValueList[2], reqPacket2.ValueList[2]); }
public void TestMethod_PKTArrayTest1EnDecode() { var reqPacket = new PKTArrayTest1(); reqPacket.Count = 3; reqPacket.ValueList.AddRange(new int[] { 4, 7, 2 }); var packetData = new List <byte>(); PKTArrayTest1EnDecode.Encode(packetData, reqPacket); var reqPacket2 = new PKTArrayTest1(); PKTArrayTest1EnDecode.Decode(packetData.ToArray(), ref reqPacket2); Assert.AreEqual(reqPacket.Count, reqPacket2.Count); Assert.AreEqual(reqPacket.ValueList[0], reqPacket2.ValueList[0]); Assert.AreEqual(reqPacket.ValueList[1], reqPacket2.ValueList[1]); Assert.AreEqual(reqPacket.ValueList[2], reqPacket2.ValueList[2]); }
public static void Encode(List <byte> packetData, PKTArrayTest1 packet) { packetData.AddRange(BitConverter.GetBytes(packet.Count)); PacketEnDecodeUtil.ArrayTo(packet.ValueList, packetData); }
public static bool Decode(byte[] packetData, ref PKTArrayTest1 packet) { int readPos = 0; packet.Count = BitConverter.ToInt16(packetData, readPos); readPos += 2; PacketEnDecodeUtil.ToCollection(packetData, ref readPos, packet.Count, packet.ValueList); return true; }
public static void Encode(List<byte> packetData, PKTArrayTest1 packet) { packetData.AddRange(BitConverter.GetBytes(packet.Count)); PacketEnDecodeUtil.ArrayTo(packet.ValueList, packetData); }