コード例 #1
0
        /// <summary> Write a Definition XML Element from attributes in a member. </summary>
        public virtual void WriteDefinition(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, DefinitionAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass)
        {
            writer.WriteStartElement( "definition" );
            // Attribute: <class>
            writer.WriteAttributeString("class", attribute.Class==null ? DefaultHelper.Get_Definition_Class_DefaultValue(member) : GetAttributeValue(attribute.Class, mappedClass));

            WriteUserDefinedContent(writer, member, null, attribute);

            System.Collections.ArrayList memberAttribs = GetSortedAttributes(member);
            int attribPos; // Find the position of the DefinitionAttribute (its <sub-element>s must be after it)
            for(attribPos=0; attribPos<memberAttribs.Count; attribPos++)
                if( memberAttribs[attribPos] is DefinitionAttribute
                    && ((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 DefinitionAttribute )
                        break; // Following attributes are for this Definition
                    if( memberAttrib is ParamAttribute )
                        WriteParam(writer, member, memberAttrib as ParamAttribute, attribute, mappedClass);
                }
            }
            WriteUserDefinedContent(writer, member, typeof(ParamAttribute), attribute);

            writer.WriteEndElement();
        }