Microsoft.Protocols.TestSuites.Common.TypedString.Size C# (CSharp) Method

Size() public method

Return the size of TypedString structure.
public Size ( ) : int
return int
        public int Size()
        {
            int size = 0;
            int length = 0;
            size += sizeof(byte);
            switch (this.StringType)
            {
                // There is no string represent
                case (byte)TestSuites.Common.StringType.None:
                // The string is empty
                case (byte)TestSuites.Common.StringType.Empty:
                    break;

                // Null-terminated 8-bit character string
                case (byte)TestSuites.Common.StringType.CharacterString:
                // Null-terminated Reduced Unicode character string
                case (byte)TestSuites.Common.StringType.ReducedUnicodeCharacterString:
                    while (true)
                    {
                        // Terminator found
                        if (this.String[length++] == '\0')
                        {
                            break;
                        }
                    }

                    size += length;
                    break;

                // Null-terminated Unicode character string
                case (byte)TestSuites.Common.StringType.UnicodeCharacterString:
                    while (true)
                    {
                        // Terminator found
                        if ((this.String[length++] == '\0') &&
                            (this.String[length++] == '\0'))
                        {
                            break;
                        }
                    }

                    size += length;
                    break;

                // Undefined flag
                default:
                    break;
            }

            return size;
        }
    }