Microsoft.Protocols.TestSuites.Common.FlaggedPropertyValueWithType.Parse C# (CSharp) Method

Parse() public method

Parse bytes in context into a FlaggedPropertyValueWithTypeNode
public Parse ( Context context ) : void
context Context The value of Context
return void
        public override void Parse(Context context)
        {
            // Parse Type
            if (context.AvailBytes() < sizeof(ushort))
            {
                throw new ParseException("not well formed FlaggedPropertyValueWithTypeNode with PropertyType missed");
            }
            else
            {
                context.CurProperty.Type = (PropertyType)BitConverter.ToUInt16(context.PropertyBytes, context.CurIndex);
                context.CurIndex += 2;
                this.PropertyType = (ushort)context.CurProperty.Type;
                base.Parse(context);
            }

            // Parse flag
            if (context.AvailBytes() < sizeof(byte))
            {
                throw new ParseException("not well formed FlaggedPropertyValueWithTypeNode with PropertyFlag missed");
            }

            this.Flag = context.PropertyBytes[context.CurIndex++];
            switch (this.Flag)
            {
                // Indicates PropertyValue presents
                case 0:
                    break;

                // Indicates PropertyValue not presents
                case 1:
                    return;

                // Indicates error for this property
                case 0xA:

                    // Define 0xFFFF as a Property that contains error code
                    context.CurProperty.Type = (PropertyType)0xFFFF;
                    break;

                // Not defined value
                default:
                    return;
            }

            // Parse content
            base.Parse(context);
        }
    }
FlaggedPropertyValueWithType