Monobjc.Tools.Generator.Parsers.Sgml.AttDef.SetEnumeratedType C# (CSharp) Method

SetEnumeratedType() public method

Sets the attribute definition to have an enumerated value.
If the type parameter is not either or .
public SetEnumeratedType ( string enumValues, AttributeType type ) : void
enumValues string The possible values in the enumeration.
type AttributeType The type to set the attribute to.
return void
        public void SetEnumeratedType(string[] enumValues, AttributeType type)
        {
            if (type != AttributeType.ENUMERATION && type != AttributeType.NOTATION)
            {
                throw new ArgumentException(string.Format(CultureInfo.CurrentUICulture, "AttributeType {0} is not valid for an attribute definition with an enumerated value.", type));
            }

            this.m_enumValues = enumValues;
            this.m_type = type;
        }

Usage Example

Esempio n. 1
0
        private void ParseAttType(char ch, AttDef attdef)
        {
            if (ch == '%')
            {
                Entity e = this.ParseParameterEntity(WhiteSpace);
                this.PushEntity(this.m_current.ResolvedUri, e);
                this.ParseAttType(this.m_current.Lastchar, attdef);
                this.PopEntity(); // bugbug - are we at the end of the entity?
                ch = this.m_current.Lastchar;
                return;
            }

            if (ch == '(')
            {
                //attdef.EnumValues = ParseNameGroup(ch, false);
                //attdef.Type = AttributeType.ENUMERATION;
                attdef.SetEnumeratedType(this.ParseNameGroup(ch, false), AttributeType.ENUMERATION);
            }
            else
            {
                string token = this.ScanName(WhiteSpace);
                if (string.Equals(token, "NOTATION", StringComparison.OrdinalIgnoreCase))
                {
                    ch = this.m_current.SkipWhitespace();
                    if (ch != '(')
                    {
                        this.m_current.Error("Expecting name group '(', but found '{0}'", ch);
                    }
                    //attdef.Type = AttributeType.NOTATION;
                    //attdef.EnumValues = ParseNameGroup(ch, true);
                    attdef.SetEnumeratedType(this.ParseNameGroup(ch, true), AttributeType.NOTATION);
                }
                else
                {
                    attdef.SetType(token);
                }
            }
        }