Microsoft.Protocols.TestSuites.Common.RopSetColumnsResponse.Deserialize C# (CSharp) Method

Deserialize() public method

Deserialize the ROP response buffer.
public Deserialize ( byte ropBytes, int startIndex ) : int
ropBytes byte ROPs bytes in response.
startIndex int The start index of this ROP.
return int
        public int Deserialize(byte[] ropBytes, int startIndex)
        {
            int index = startIndex;
            this.RopId = ropBytes[index++];
            this.InputHandleIndex = ropBytes[index++];
            this.ReturnValue = (uint)BitConverter.ToInt32(ropBytes, index);
            index += sizeof(uint);

            // Only success response has below fields
            if (this.ReturnValue == 0)
            {
                this.TableStatus = ropBytes[index++];
            }
            else
            {
                this.TableStatus = 0;
            }

            return index - startIndex;
        }
    }

Usage Example

        /// <summary>
        /// Parses a response with multiple ROPs. In this scenario, the response is designed as only containing two ROPs: RopSetColumn and RopQueryRows.
        /// </summary>
        /// <param name="rgbOutput">The raw data that contains the ROP response payload</param>
        /// <returns>The ROP response list which contains RopSetColumnResponse and RopQueryRawResponse</returns>
        private List<IDeserializable> ParseMultipleRopsResponse(byte[] rgbOutput)
        {
            int parseByteLength = 0;
            List<IDeserializable> multipleRopsResponse = new List<IDeserializable>();
            RPC_HEADER_EXT rpcHeader = new RPC_HEADER_EXT
            {
                Version = BitConverter.ToUInt16(rgbOutput, parseByteLength)
            };

            // Parse RPC_HEADER_EXT structure
            parseByteLength += sizeof(short);
            rpcHeader.Flags = BitConverter.ToUInt16(rgbOutput, parseByteLength);
            parseByteLength += sizeof(short);
            rpcHeader.Size = BitConverter.ToUInt16(rgbOutput, parseByteLength);
            parseByteLength += sizeof(short);
            rpcHeader.SizeActual = BitConverter.ToUInt16(rgbOutput, parseByteLength);
            parseByteLength += sizeof(short);

            // Passed 2 bytes which is size of ROP response.
            parseByteLength += sizeof(short);

            // Parse RopSetColumns response
            RopSetColumnsResponse setColumnsResponse = new RopSetColumnsResponse();
            parseByteLength += setColumnsResponse.Deserialize(rgbOutput, parseByteLength);

            // Parse RopQueryRows response
            RopQueryRowsResponse queryRowsResponse = new RopQueryRowsResponse();
            parseByteLength += queryRowsResponse.Deserialize(rgbOutput, parseByteLength);

            multipleRopsResponse.Add(setColumnsResponse);
            multipleRopsResponse.Add(queryRowsResponse);

            return multipleRopsResponse;
        }
RopSetColumnsResponse