Microsoft.Protocols.TestSuites.Common.RopCreateFolderResponse.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)
        {
            // Because HasRules is byte type, has default value 0, can't check it whether present
            // Set HasRules to null to decide it present, if equal 0xFF means not present else present
            this.HasRules = null;
            int index = startIndex;
            this.RopId = ropBytes[index++];
            this.OutputHandleIndex = ropBytes[index++];
            this.ReturnValue = (uint)BitConverter.ToInt32(ropBytes, index);
            index += sizeof(uint);
                                                                                                                                                                             
            // Only success response has below fields
            if (this.ReturnValue == 0)
            {
                this.FolderId = (ulong)BitConverter.ToInt64(ropBytes, index);
                index += sizeof(ulong);
                this.IsExistingFolder = ropBytes[index++];
                if (this.IsExistingFolder != 0)
                {
                    this.HasRules = ropBytes[index++];
                    this.IsGhosted = ropBytes[index++];
                    if (this.IsGhosted != 0)
                    {
                        this.ServerCount = (ushort)BitConverter.ToInt16(ropBytes, index);
                        index += sizeof(ushort);
                        this.CheapServerCount = (ushort)BitConverter.ToInt16(ropBytes, index);
                        index += sizeof(ushort);
                        if (this.ServerCount > 0)
                        {
                            this.Servers = new string[(ushort)this.ServerCount];
                            for (int i = 0; i < this.ServerCount; 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.Servers[i] = Encoding.ASCII.GetString(ropBytes, index, bytesLen);                              
                                index += bytesLen;
                            }
                        }
                    }
                }
            }
                                                                                                                                                                                                
            return index - startIndex;
        }
    }
RopCreateFolderResponse