Microsoft.Protocols.TestSuites.Common.NotificationData.ParseString C# (CSharp) Method

ParseString() private method

Parse a string
private ParseString ( int &index, byte &ropBytes ) : void
index int The index of current byte
ropBytes byte ROPs bytes
return void
        private void ParseString(ref int index, ref byte[] ropBytes)
        {
            int strBytesLen = 0;
            bool isFound = false;

            // Unicode
            if (this.UnicodeFlag != 0x0)
            {
                for (int i = index; i < ropBytes.Length; i += 2)
                {
                    strBytesLen += 2;
                    if ((ropBytes[i] == 0) && (ropBytes[i + 1] == 0))
                    {
                        isFound = true;
                        break;
                    }
                }
            }
            else
            {
                // Find the string with '\0' end
                for (int i = index; i < ropBytes.Length; i++)
                {
                    strBytesLen++;
                    if (ropBytes[i] == 0)
                    {
                        isFound = true;
                        break;
                    }
                }
            }

            if (!isFound)
            {
                throw new ParseException("String too long or not found");
            }
            else
            {
                this.MessageClass = new byte[strBytesLen];
                Array.Copy(ropBytes, index, this.MessageClass, 0, strBytesLen - 1);
                index += strBytesLen;
            }
        }
    }