Microsoft.Protocols.TestSuites.Common.RopGetOwningServersResponse.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.OwningServersCount = (ushort)BitConverter.ToInt16(ropBytes, index);
                index += sizeof(ushort);
                this.CheapServersCount = (ushort)BitConverter.ToInt16(ropBytes, index);
                index += sizeof(ushort);
                if (this.OwningServersCount > 0)
                {
                    this.OwningServers = new string[this.OwningServersCount];
                    for (int i = 0; i < this.OwningServersCount; i++)
                    {
                        int bytesLen = 0;

                        // Find the string with '\0' end
                        for (int j = index; j < ropBytes.Length; j++)
                        {
                            bytesLen++;
                            if (ropBytes[j] == 0)
                            {
                                break;
                            }
                        }

                        this.OwningServers[i] = Encoding.ASCII.GetString(ropBytes, index, bytesLen);
                        index += bytesLen;
                    }
                }
            }

            return index - startIndex;
        }
    }
RopGetOwningServersResponse