Example #1
0
        public void ParseTypeAttributeTest()
        {
            //Parse tokens
            MarkupParser  markupParser        = new MarkupParser(Init("type1"));
            TypeAttribute parsedTypeAttribute = markupParser.ParseTypeAttribute();

            //Check Id Attribute
            Assert.AreEqual("type1", parsedTypeAttribute.GetType());
        }
        /// <summary> Write a Type XML Element from attributes in a member. </summary>
        public virtual void WriteType(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, TypeAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass)
        {
            writer.WriteStartElement( "type" );
            // Attribute: <name>
            writer.WriteAttributeString("name", attribute.Name==null ? DefaultHelper.Get_Type_Name_DefaultValue(member) : GetAttributeValue(attribute.Name, mappedClass));

            WriteUserDefinedContent(writer, member, null, attribute);

            System.Collections.ArrayList memberAttribs = GetSortedAttributes(member);
            int attribPos; // Find the position of the TypeAttribute (its <sub-element>s must be after it)
            for(attribPos=0; attribPos<memberAttribs.Count; attribPos++)
                if( memberAttribs[attribPos] is TypeAttribute
                    && ((BaseAttribute)memberAttribs[attribPos]).Position == attribute.Position )
                    break; // found
            int i = attribPos + 1;

            // Element: <param>
            for(; i<memberAttribs.Count; i++)
            {
                BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute;
                if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType())
                    || IsNextElement(memberAttrib, attribute, typeof(ParamAttribute)) )
                    break; // next attributes are 'elements' of the same level OR for 'sub-elements'
                else
                {
                    if( memberAttrib is TypeAttribute )
                        break; // Following attributes are for this Type
                    if( memberAttrib is ParamAttribute )
                        WriteParam(writer, member, memberAttrib as ParamAttribute, attribute, mappedClass);
                }
            }
            WriteUserDefinedContent(writer, member, typeof(ParamAttribute), attribute);

            writer.WriteEndElement();
        }
Example #3
0
 /// <summary>
 /// Interpret TypeAttribute
 /// </summary>
 /// <param name="attribute">TypeAttribute to interpret</param>
 public override void Visit(TypeAttribute attribute)
 {   //Add type attribute
     Current.AddAttribute("type", attribute.GetType());
 }