Microsoft.Protocols.TestTools.StackSdk.BranchCache.Pccrr.PccrrGETBLKLISTRequestPacket.Encode C# (CSharp) Method

Encode() public method

Encode pack.
public Encode ( ) : byte[]
return byte[]
        public override byte[] Encode()
        {
            REQUEST_MESSAGE requestMessage = new REQUEST_MESSAGE();
            requestMessage.MESSAGEBODY = this.msgGetBLKLIST;
            requestMessage.MESSAGEHEADER = this.MessageHeader;
            byte[] ret;

            List<byte> temp = new List<byte>();
            byte[] tempPayload;
            List<byte> listRet = new List<byte>();
            listRet.AddRange(MarshalHelper.GetBytes(((MSG_GETBLKLIST)requestMessage.MESSAGEBODY).SizeOfSegmentID, false));
            listRet.AddRange(((MSG_GETBLKLIST)requestMessage.MESSAGEBODY).SegmentID);
            while (listRet.Count % 4 != 0)
            {
                listRet.Add(byte.MinValue);
            }

            listRet.AddRange(MarshalHelper.GetBytes(((MSG_GETBLKLIST)requestMessage.MESSAGEBODY).NeededBlocksRangeCount, false));
            for (int i = 0; i < ((MSG_GETBLKLIST)requestMessage.MESSAGEBODY).NeededBlockRanges.Length; i++)
            {
                listRet.AddRange(MarshalHelper.GetBytes(((MSG_GETBLKLIST)requestMessage.MESSAGEBODY).NeededBlockRanges[i].Index, false));
                listRet.AddRange(MarshalHelper.GetBytes(((MSG_GETBLKLIST)requestMessage.MESSAGEBODY).NeededBlockRanges[i].Count, false));
            }

            tempPayload = listRet.ToArray();

            requestMessage.MESSAGEHEADER.MsgSize = (uint)tempPayload.Length + 16;

            List<byte> listRet1 = new List<byte>();
            listRet1.AddRange(MarshalHelper.GetBytes((ushort)requestMessage.MESSAGEHEADER.ProtVer.MinorVersion, false));
            listRet1.AddRange(MarshalHelper.GetBytes((ushort)requestMessage.MESSAGEHEADER.ProtVer.MajorVersion, false));
            listRet1.AddRange(MarshalHelper.GetBytes((uint)requestMessage.MESSAGEHEADER.MsgType, false));
            listRet1.AddRange(MarshalHelper.GetBytes(requestMessage.MESSAGEHEADER.MsgSize, false));
            listRet1.AddRange(MarshalHelper.GetBytes((uint)requestMessage.MESSAGEHEADER.CryptoAlgoId, false));

            temp.AddRange(listRet1.ToArray());
            temp.AddRange(tempPayload);
            ret = (byte[])temp.ToArray();

            return ret;
        }