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

SetType() public method

Sets the type of the attribute definition.
public SetType ( string type ) : void
type string The string representation of the attribute type, corresponding to the values in the enumeration.
return void
        public void SetType(string type)
        {
            switch (type)
            {
                case "CDATA":
                    this.m_type = AttributeType.CDATA;
                    break;
                case "ENTITY":
                    this.m_type = AttributeType.ENTITY;
                    break;
                case "ENTITIES":
                    this.m_type = AttributeType.ENTITIES;
                    break;
                case "ID":
                    this.m_type = AttributeType.ID;
                    break;
                case "IDREF":
                    this.m_type = AttributeType.IDREF;
                    break;
                case "IDREFS":
                    this.m_type = AttributeType.IDREFS;
                    break;
                case "NAME":
                    this.m_type = AttributeType.NAME;
                    break;
                case "NAMES":
                    this.m_type = AttributeType.NAMES;
                    break;
                case "NMTOKEN":
                    this.m_type = AttributeType.NMTOKEN;
                    break;
                case "NMTOKENS":
                    this.m_type = AttributeType.NMTOKENS;
                    break;
                case "NUMBER":
                    this.m_type = AttributeType.NUMBER;
                    break;
                case "NUMBERS":
                    this.m_type = AttributeType.NUMBERS;
                    break;
                case "NUTOKEN":
                    this.m_type = AttributeType.NUTOKEN;
                    break;
                case "NUTOKENS":
                    this.m_type = AttributeType.NUTOKENS;
                    break;
                default:
                    throw new SgmlParseException(string.Format(CultureInfo.CurrentUICulture, "Attribute type '{0}' is not supported", 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);
                }
            }
        }