PropertyValueNode with property's value, Type and flag
Наследование: PropertyValue
Пример #1
0
        /// <summary>
        /// Parse bytes in context into a PropertyRowNode
        /// </summary>
        /// <param name="context">The value of Context</param>
        public override void Parse(Context context)
        {
            // Clear PropertyValues to store parsing result
            this.propertyValues.Clear();

            // Flag indicates the Type of PropertyRow
            this.flag = context.PropertyBytes[context.CurIndex++];

            foreach (Property prop in context.Properties)
            {
                if (context.IsEnd())
                {
                    throw new ParseException("End prematurely");
                }

                PropertyValue valueNode = null;

                if (this.flag == 0)
                {
                    // StandardPropertyRow
                    if (prop.Type == PropertyType.PtypUnspecified)
                    {
                        valueNode = new TypedPropertyValue();
                    }
                    else
                    {
                        valueNode = new PropertyValue();
                    }
                }
                else
                {
                    // FlaggedPropertyRow
                    if (prop.Type == PropertyType.PtypUnspecified)
                    {
                        valueNode = new FlaggedPropertyValueWithType();
                    }
                    else
                    {
                        valueNode = new FlaggedPropertyValue();
                    }
                }

                context.CurProperty = new Property((PropertyType)prop.Type);
                valueNode.Parse(context);
                this.propertyValues.Add(valueNode);
            }
        }
Пример #2
0
        /// <summary>
        /// Parse bytes in context into a PropertyRowNode
        /// </summary>
        /// <param name="context">The value of Context</param>
        public override void Parse(Context context)
        {
            // Clear PropertyValues to store parsing result
            this.propertyValues.Clear();

            // Flag indicates the Type of PropertyRow
            this.flag = context.PropertyBytes[context.CurIndex++];

            foreach (Property prop in context.Properties)
            {
                if (context.IsEnd())
                {
                    throw new ParseException("End prematurely");
                }
                
                PropertyValue valueNode = null;

                if (this.flag == 0)
                {
                    // StandardPropertyRow
                    if (prop.Type == PropertyType.PtypUnspecified)
                    {
                        valueNode = new TypedPropertyValue();
                    }
                    else
                    {
                        valueNode = new PropertyValue();
                    }
                }
                else
                {
                    // FlaggedPropertyRow
                    if (prop.Type == PropertyType.PtypUnspecified)
                    {
                        valueNode = new FlaggedPropertyValueWithType();
                    }
                    else
                    {
                        valueNode = new FlaggedPropertyValue();
                    }
                }

                context.CurProperty = new Property((PropertyType)prop.Type);
                valueNode.Parse(context);
                this.propertyValues.Add(valueNode);
            }
        }