/// <summary>
        /// Adds a table of the <paramref name="types"/> to the document with a header <paramref name="name"/>.
        /// </summary>
        /// <param name="name">The header text.</param>
        /// <param name="types">The types to add to the table.</param>
        /// <param name="xmlFile">The XML file to read comments from.</param>
        private void OutputTypes(string name, IOrderedEnumerable <TypeDef> types, ICommentSource xmlFile)
        {
            if (types.Count() != 0)
            {
                SummaryTable classTable = new SummaryTable();
                foreach (TypeDef currentType in types)
                {
                    CRefPath crefPath = new CRefPath(currentType);

                    // Find the description for the type
                    Block description = this.GetSummaryFor(
                        xmlFile,
                        currentType.Assembly,
                        crefPath
                        );
                    Hyperlink nameLink = new Hyperlink(new Run(currentType.GetDisplayName(false)));
                    nameLink.Tag    = new EntryKey(currentType.GetGloballyUniqueId());
                    nameLink.Click += new System.Windows.RoutedEventHandler(LinkHelper.Resolve);
                    classTable.AddItem(nameLink, description, Model.ElementIconConstants.GetIconPathFor(currentType));
                }
                this.Blocks.Add(new Header2(name));
                this.Blocks.Add(classTable);
            }
        }
Exemple #2
0
        public void PathTypesShouldBeSetCorrectly(string path, CRefTypes expectedType)
        {
            CRefPath converted = CRefPath.Parse(path);

            Assert.AreEqual(expectedType, converted.PathType);
        }
Exemple #3
0
        public void WhenNamespaceTypeWithName_Parse_SetsNamespace()
        {
            CRefPath path = CRefPath.Parse("N:System");

            Assert.AreEqual("System", path.Namespace);
        }
Exemple #4
0
        public void WhenEmptyNamespace_Parse_NamespaceIsEmptyString()
        {
            CRefPath path = CRefPath.Parse("N:");

            Assert.AreEqual(string.Empty, path.Namespace);
        }
Exemple #5
0
        public override void Generate()
        {
            if (!IsGenerated)
            {
                TypeDef definingType = null;
                if (_typesMethods != null && _typesMethods.Count > 0)
                {
                    definingType = _typesMethods[0].Type as TypeDef;
                }

                if (!_xmlComments.Exists())
                {
                    Blocks.Add(new NoXmlComments(definingType));
                }

                Blocks.Add(new Header1(definingType.GetDisplayName(false) + " Methods"));

                if (_typesMethods != null && _typesMethods.Count > 0)
                {
                    SummaryTable methods = new SummaryTable();

                    var sortedMethods = from method in this._typesMethods
                                        where !method.IsConstructor
                                        orderby method.Name
                                        where !LiveDocumentorFile.Singleton.LiveDocument.IsMemberFiltered(method)
                                        select method;

                    foreach (MethodDef currentMethod in sortedMethods)
                    {
                        System.Windows.Documents.Hyperlink link = new System.Windows.Documents.Hyperlink();
                        link.Inlines.Add(new System.Windows.Documents.Run(currentMethod.GetDisplayName(false)));
                        link.Tag    = new EntryKey(currentMethod.GetGloballyUniqueId());
                        link.Click += new System.Windows.RoutedEventHandler(LinkHelper.Resolve);

                        CRefPath path = new CRefPath(currentMethod);

                        System.Windows.Documents.Block description = this.GetSummaryFor(_xmlComments,
                                                                                        currentMethod.Assembly,
                                                                                        path
                                                                                        );

                        methods.AddItem(link, description, Model.ElementIconConstants.GetIconPathFor(currentMethod));
                    }
                    Blocks.Add(methods);
                }

                if (definingType != null && definingType.ExtensionMethods.Count > 0)
                {
                    SummaryTable methods = new SummaryTable();

                    var sortedMethods = from method in definingType.ExtensionMethods
                                        where !method.IsConstructor
                                        orderby method.Name
                                        where !LiveDocumentorFile.Singleton.LiveDocument.IsMemberFiltered(method)
                                        select method;

                    foreach (MethodDef currentMethod in sortedMethods)
                    {
                        DisplayNameSignitureConvertor      displayNameSig = new DisplayNameSignitureConvertor(currentMethod, false, true, true);
                        System.Windows.Documents.Hyperlink link           = new System.Windows.Documents.Hyperlink();
                        link.Inlines.Add(new System.Windows.Documents.Run(displayNameSig.Convert()));
                        link.Tag    = new EntryKey(currentMethod.GetGloballyUniqueId());
                        link.Click += new System.Windows.RoutedEventHandler(LinkHelper.Resolve);

                        CRefPath path = new CRefPath(currentMethod);

                        System.Windows.Documents.Block description = this.GetSummaryFor(_xmlComments,
                                                                                        currentMethod.Assembly,
                                                                                        path
                                                                                        );

                        methods.AddItem(link, description, Model.ElementIconConstants.GetIconPathFor(currentMethod));
                    }
                    Blocks.Add(new Header2("Extension Methods"));
                    Blocks.Add(methods);
                }

                IsGenerated = true;
                // we also no longer need to store a reference to the XML file I think so we can remove it
                _xmlComments  = null;
                _typesMethods = null;
            }
        }
Exemple #6
0
        /// <summary>
        /// Add the parameters section for the provided <paramref name="mathod"/>.
        /// </summary>
        /// <param name="method">The method to add the parameters for.</param>
        /// <param name="parsedBlocks">The parsed comments.</param>
        protected void AddParametersForMethod(MethodDef method, List <Block> parsedBlocks)
        {
            // Add the parameter information if available
            List <Param> parameterComments = Parser.ParseElement <Param>(parsedBlocks);

            if (method.Parameters != null && method.Parameters.Count > 0)
            {
                ParameterList parameters = null;
                foreach (ParamDef methodParam in method.Parameters)
                {
                    if (methodParam.Sequence != 0)
                    {
                        // Find the parameter comments
                        Param paramComment = null;
                        foreach (Param current in parameterComments)
                        {
                            if (current.Name == methodParam.Name)
                            {
                                paramComment = current;
                                break;
                            }
                        }

                        TypeRef  typeRef  = method.ResolveParameter(methodParam.Sequence);
                        EntryKey typeKey  = null;
                        string   typeName = typeRef.Name;
                        if (parameters == null)
                        {
                            parameters = new ParameterList();
                        }
                        if (typeRef != null)
                        {
                            if (typeRef is TypeDef)
                            {
                                typeKey = new EntryKey(typeRef.GetGloballyUniqueId());
                            }
                            else
                            {
                                CRefPath            path  = new CRefPath(typeRef);
                                Documentation.Entry found = LiveDocumentorFile.Singleton.LiveDocument.Find(path);
                                if (found != null)
                                {
                                    typeKey  = new EntryKey(found.Key);
                                    typeName = found.Name;
                                }
                                else
                                {
                                    typeKey = null;
                                }
                            }
                            typeName = typeRef.GetDisplayName(false);
                        }
                        List <Block> paramDescription = new List <Block>();
                        if (paramComment != null && paramComment.Description != null)
                        {
                            paramDescription = paramComment.Description;
                        }
                        parameters.Add(methodParam.Name, typeName, method.Assembly, typeKey, paramDescription);
                    }
                }
                if (parameters != null)
                {
                    this.Blocks.Add(parameters);
                }
            }
        }
Exemple #7
0
        /// <summary>
        /// Generates the contents of the page, utilising details of the
        /// type and its associated xml comments.
        /// </summary>
        public override void Generate()
        {
            if (!this.IsGenerated)
            {
                CRefPath     crefPath     = new CRefPath(this._representedType);
                List <Block> parsedBlocks = Elements.Parser.Parse(this._representedType.Assembly, _commentsXml, crefPath);

                if (!_commentsXml.Exists())
                {
                    this.Blocks.Add(new NoXmlComments(this._representedType));
                }

                this.Blocks.Add(new Header1(this._representedType.Name + " Enumeration"));

                // Add the summary if it exists
                if (parsedBlocks != null)
                {
                    Block summary = parsedBlocks.Find(currentBlock => currentBlock is Summary);
                    if (summary != null)
                    {
                        this.Blocks.Add(summary);
                    }
                }

                this.AddSyntaxBlock(this._representedType);

                // Add the table of classes to the page
                List <FieldDef> fields       = this._representedType.GetFields();
                SummaryTable    classTable   = new SummaryTable("Member Name", "Description", false);
                var             sortedFields = from field in fields
                                               orderby field.Name
                                               select field;
                foreach (FieldDef currentField in sortedFields)
                {
                    if (currentField.IsSystemGenerated)
                    {
                        continue;
                    }
                    Block description = this.GetSummaryFor(
                        _commentsXml,
                        currentField.Assembly,
                        new CRefPath(currentField)
                        );
                    classTable.AddItem(currentField.Name, description);
                }
                this.Blocks.Add(new Header2("Members"));
                this.Blocks.Add(classTable);

                if (parsedBlocks != null)
                {
                    Block permissions = parsedBlocks.Find(current => current is PermissionList);
                    if (permissions != null)
                    {
                        this.Blocks.Add(permissions);
                    }
                }

                // Add the remarks if it exists
                if (parsedBlocks != null)
                {
                    Block remarks = parsedBlocks.Find(currentBlock => currentBlock is Remarks);
                    if (remarks != null)
                    {
                        this.Blocks.Add(remarks);
                    }
                }

                // Add the example if it exists
                if (parsedBlocks != null)
                {
                    Block summary = parsedBlocks.Find(currentBlock => currentBlock is Example);
                    if (summary != null)
                    {
                        this.Blocks.Add(new Header2("Examples"));
                        this.Blocks.Add(summary);
                    }
                }

                // Add the seealso list if it exists
                this.AddSeeAlso(parsedBlocks);

                this.IsGenerated = true;
            }
        }
Exemple #8
0
        /// <summary>
        /// Loads and parses the XML Code comments for the <paramref name="crefPathToMember"/> specified
        /// element.
        /// </summary>
        /// <param name="assembly">The assembly the member is defined in.</param>
        /// <param name="file">The file containing the xml code comments</param>
        /// <param name="crefPathToMember">The conical name path to the member to get documentation for.</param>
        /// <returns>A List of blocks for the members commentary.</returns>
        public static List <Block> Parse(AssemblyDef assembly, ICommentSource file, CRefPath crefPathToMember)
        {
            XmlCodeComment comment = file.GetComment(crefPathToMember);

            return(Parser.Parse(assembly, comment));
        }
        public override void Render(System.Xml.XmlWriter writer)
        {
            CRefPath       crefPath = new CRefPath(_member);
            XmlCodeComment comment  = _xmlComments.GetComment(crefPath);

            writer.WriteStartElement("member");
            writer.WriteAttributeString("id", AssociatedEntry.Key.ToString());
            writer.WriteAttributeString("subId", AssociatedEntry.SubKey);
            writer.WriteAttributeString("type", ReflectionHelper.GetType(_member));
            writer.WriteAttributeString("cref", crefPath.ToString());
            writer.WriteStartElement("name");
            writer.WriteAttributeString("safename", Exporter.CreateSafeName(_member.Name));
            writer.WriteString(_member.Name);
            writer.WriteEndElement();

            writer.WriteStartElement("namespace");
            Entry namespaceEntry = this.AssociatedEntry.FindNamespace(_member.Type.Namespace);

            writer.WriteAttributeString("id", namespaceEntry.Key.ToString());
            writer.WriteAttributeString("name", namespaceEntry.SubKey);
            writer.WriteAttributeString("cref", $"N:{_member.Type.Namespace}");
            writer.WriteString(_member.Type.Namespace);
            writer.WriteEndElement();
            writer.WriteStartElement("assembly");
            writer.WriteAttributeString("file", System.IO.Path.GetFileName(_member.Assembly.FileName));
            writer.WriteString(_member.Assembly.Name);
            writer.WriteEndElement();

            // find and output the summary
            if (comment != XmlCodeComment.Empty)
            {
                XmlCodeElement summary = comment.Elements.Find(currentBlock => currentBlock is SummaryXmlCodeElement);
                if (summary != null)
                {
                    Serialize(summary, writer);
                }
            }

            this.RenderPermissionBlock(_member, writer, comment);
            this.RenderSyntaxBlocks(_member, writer);

            // find and output the value
            if (comment != XmlCodeComment.Empty)
            {
                XmlCodeElement remarks = comment.Elements.Find(currentBlock => currentBlock is ValueXmlCodeElement);
                if (remarks != null)
                {
                    Serialize(remarks, writer);
                }
            }

            // find and output the summary
            if (comment != XmlCodeComment.Empty)
            {
                XmlCodeElement remarks = comment.Elements.Find(currentBlock => currentBlock is RemarksXmlCodeElement);
                if (remarks != null)
                {
                    Serialize(remarks, writer);
                }
            }

            // find and output the examples
            if (comment != XmlCodeComment.Empty)
            {
                XmlCodeElement remarks = comment.Elements.Find(currentBlock => currentBlock is ExampleXmlCodeElement);
                if (remarks != null)
                {
                    Serialize(remarks, writer);
                }
            }

            RenderSeeAlsoBlock(_member, writer, comment);

            writer.WriteEndElement();
        }
        /// <summary>
        /// Searches the Document for the entry related to the specified <paramref name="path"/>.
        /// </summary>
        /// <param name="path">The CRefPath to search for.</param>
        /// <returns>The Entry if it is found else null.</returns>
        public Entry Find(CRefPath path)
        {
            if (path == null || path.PathType == CRefTypes.Error)
            {
                return(null);
            }
            if (Map.Count == 0)
            {
                return(null);
            }

            // find the level of the namespace entries
            int   level = 1;
            Entry found = Map[0];

            while (!(found.Item is KeyValuePair <string, List <TypeDef> >))
            {
                found = found.Children[0];
                level++;
            }
            found = null;

            List <Entry> namespaceEntries = new List <Entry>();   // flattend list of namespaces

            if (level == 1)
            {
                namespaceEntries.AddRange(Map);
            }
            else
            {
                for (int i = 0; i < Map.Count; i++)
                {
                    namespaceEntries.AddRange(GetAllEntriesFromLevel(level, 2, Map[i]));
                }
            }

            for (int i = 0; i < namespaceEntries.Count; i++)
            {
                Entry currentLevel = namespaceEntries[i];
                if (string.Compare(currentLevel.SubKey, path.Namespace, true) == 0)
                {
                    // if we are searching for a namespace, we are done now as we have found it
                    if (path.PathType == CRefTypes.Namespace)
                    {
                        found = currentLevel;
                        break;
                    }

                    // search the types in the namespace
                    for (int j = 0; j < currentLevel.Children.Count; j++)
                    {
                        Entry   currentTypeEntry = currentLevel.Children[j];
                        TypeDef currentType      = (TypeDef)currentTypeEntry.Item;
                        if (string.Compare(currentType.Name, path.TypeName, true) == 0)
                        {
                            // if we are searchinf for a type, we are done now
                            if (path.PathType == CRefTypes.Type)
                            {
                                found = currentTypeEntry;
                                break;
                            }

                            // find the type and do the quick type search to find the related
                            // entry. this is the quickest way.
                            ReflectedMember member = path.FindIn(currentType);
                            if (member != null)
                            {   // someone could have misspelled the member in the crefpath
                                found = currentTypeEntry.FindByKey(member.GetGloballyUniqueId(), string.Empty);
                                break;
                            }
                        }
                    }
                }
                if (found != null)
                {
                    break;
                }
            }

            return(found);
        }
        public override void Generate()
        {
            if (!this.IsGenerated)
            {
                CRefPath     crefPath     = new CRefPath(property);
                List <Block> parsedBlocks = Elements.Parser.Parse(this.property.OwningType.Assembly, _xmlComments, crefPath);

                if (!this._xmlComments.Exists())
                {
                    this.Blocks.Add(new NoXmlComments(property));
                }

                this.Blocks.Add(new Header1(new DisplayNameSignitureConvertor(property, false, true).Convert()));

                // Add the summary if it exists
                if (parsedBlocks != null)
                {
                    Block summary = parsedBlocks.Find(currentBlock => currentBlock is Summary);
                    if (summary != null)
                    {
                        this.Blocks.Add(summary);
                    }
                }

                this.AddSyntaxBlock(this.property);

                // add parameters for indexers
                if (property.IsIndexer())
                {
                    this.AddParametersForMethod(this.property.Getter != null ? this.property.Getter : this.property.Setter, parsedBlocks);
                }

                // Add the remarks if it exists
                if (parsedBlocks != null)
                {
                    Block value = parsedBlocks.Find(currentBlock => currentBlock is Value);
                    if (value != null)
                    {
                        this.Blocks.Add(value);
                    }
                }

                // Add the exception table if it exists
                if (parsedBlocks != null)
                {
                    Block exceptions = parsedBlocks.Find(currentBlock => currentBlock is ExceptionList);
                    if (exceptions != null)
                    {
                        this.Blocks.Add(exceptions);
                    }
                }

                if (parsedBlocks != null)
                {
                    Block permissions = parsedBlocks.Find(current => current is PermissionList);
                    if (permissions != null)
                    {
                        this.Blocks.Add(permissions);
                    }
                }

                // Add the remarks if it exists
                if (parsedBlocks != null)
                {
                    Block remarks = parsedBlocks.Find(currentBlock => currentBlock is Remarks);
                    if (remarks != null)
                    {
                        this.Blocks.Add(remarks);
                    }
                }

                // Add the example if it exists
                if (parsedBlocks != null)
                {
                    Block summary = parsedBlocks.Find(currentBlock => currentBlock is Example);
                    if (summary != null)
                    {
                        this.Blocks.Add(new Header2("Examples"));
                        this.Blocks.Add(summary);
                    }
                }

                // Add the seealso list if it exists
                this.AddSeeAlso(parsedBlocks);

                this.IsGenerated = true;
            }
        }
        public override void Generate()
        {
            if (!this.IsGenerated)
            {
                CRefPath     crefPath = null;
                SummaryTable members;

                if (!this.xmlComments.Exists())
                {
                    this.Blocks.Add(new NoXmlComments(this.representedType));
                }

                this.Blocks.Add(new Header1(this.representedType.GetDisplayName(false) + " Members"));

                List <MethodDef> constructors = this.representedType.GetConstructors();
                if (constructors != null && constructors.Count > 0)
                {
                    this.Blocks.Add(new Header2("Constructors"));
                    members = new SummaryTable();
                    var sortedMethods = from method in constructors
                                        orderby method.Name
                                        where !LiveDocumentorFile.Singleton.LiveDocument.IsMemberFiltered(method)
                                        select method;
                    foreach (MethodDef currentMethod in sortedMethods)
                    {
                        crefPath = new CRefPath(currentMethod);
                        System.Windows.Documents.Hyperlink link = new System.Windows.Documents.Hyperlink();
                        link.Inlines.Add(new System.Windows.Documents.Run(currentMethod.GetDisplayName(false)));
                        link.Tag    = new EntryKey(currentMethod.GetGloballyUniqueId());
                        link.Click += new System.Windows.RoutedEventHandler(LinkHelper.Resolve);

                        Block description = this.GetSummaryFor(xmlComments,
                                                               currentMethod.Assembly,
                                                               crefPath);

                        members.AddItem(link, description, Model.ElementIconConstants.GetIconPathFor(currentMethod));
                    }
                    this.Blocks.Add(members);
                }

                List <FieldDef> fields = this.representedType.GetFields();
                if (fields != null && fields.Count > 0)
                {
                    this.Blocks.Add(new Header2("Fields"));
                    members = new SummaryTable();
                    var sortedFields = from field in fields
                                       orderby field.Name
                                       where !LiveDocumentorFile.Singleton.LiveDocument.IsMemberFiltered(field)
                                       select field;
                    foreach (FieldDef currentField in sortedFields)
                    {
                        crefPath = new CRefPath(currentField);
                        System.Windows.Documents.Hyperlink link = new System.Windows.Documents.Hyperlink();
                        link.Inlines.Add(new System.Windows.Documents.Run(currentField.Name));
                        link.Tag    = new EntryKey(currentField.GetGloballyUniqueId());
                        link.Click += new System.Windows.RoutedEventHandler(LinkHelper.Resolve);

                        Block description = this.GetSummaryFor(xmlComments,
                                                               currentField.Assembly,
                                                               crefPath);
                        Block value = this.GetSummaryFor(xmlComments,
                                                         currentField.Assembly,
                                                         crefPath);
                        if (description != null)
                        {
                            members.AddItem(link, description, Model.ElementIconConstants.GetIconPathFor(currentField));
                        }
                        else
                        {
                            members.AddItem(link, value, Model.ElementIconConstants.GetIconPathFor(currentField));
                        }
                    }
                    this.Blocks.Add(members);
                }

                List <PropertyDef> properties = this.representedType.GetProperties();
                if (properties != null && properties.Count > 0)
                {
                    this.Blocks.Add(new Header2("Properties"));
                    members = new SummaryTable();

                    var sortedProperties = from property in properties
                                           orderby new DisplayNameSignitureConvertor(property, false, true).Convert()
                                           where !LiveDocumentorFile.Singleton.LiveDocument.IsMemberFiltered(property)
                                           select property;

                    foreach (PropertyDef currentProperty in sortedProperties)
                    {
                        crefPath = new CRefPath(currentProperty);
                        System.Windows.Documents.Hyperlink link = new System.Windows.Documents.Hyperlink();
                        link.Inlines.Add(new Run(new DisplayNameSignitureConvertor(currentProperty, false, true).Convert()));
                        link.Tag    = new EntryKey(currentProperty.GetGloballyUniqueId());
                        link.Click += new System.Windows.RoutedEventHandler(LinkHelper.Resolve);

                        Block description = this.GetSummaryFor(xmlComments, currentProperty.OwningType.Assembly, crefPath);
                        members.AddItem(link, description, Model.ElementIconConstants.GetIconPathFor(currentProperty));
                    }
                    this.Blocks.Add(members);
                }

                List <EventDef> events = this.representedType.GetEvents();
                if (events != null && events.Count > 0)
                {
                    this.Blocks.Add(new Header2("Events"));
                    members = new SummaryTable();
                    var sortedEvents = from c in events
                                       orderby c.Name
                                       where !LiveDocumentorFile.Singleton.LiveDocument.IsMemberFiltered(c)
                                       select c;
                    foreach (EventDef currentEvent in sortedEvents)
                    {
                        crefPath = new CRefPath(currentEvent);
                        System.Windows.Documents.Hyperlink link = new System.Windows.Documents.Hyperlink();
                        link.Inlines.Add(new System.Windows.Documents.Run(currentEvent.Name));
                        link.Tag    = new EntryKey(currentEvent.GetGloballyUniqueId());
                        link.Click += new System.Windows.RoutedEventHandler(LinkHelper.Resolve);

                        Block description = this.GetSummaryFor(xmlComments, currentEvent.Type.Assembly,
                                                               crefPath);
                        members.AddItem(link, description, Model.ElementIconConstants.GetIconPathFor(currentEvent));
                    }
                    this.Blocks.Add(members);
                }

                List <MethodDef> methods = this.representedType.GetMethods();
                if (methods != null && methods.Count > 0)
                {
                    this.Blocks.Add(new Header2("Methods"));
                    members = new SummaryTable();
                    var sortedMethods = from method in methods
                                        orderby method.Name
                                        where !LiveDocumentorFile.Singleton.LiveDocument.IsMemberFiltered(method)
                                        select method;
                    foreach (MethodDef currentMethod in sortedMethods)
                    {
                        crefPath = new CRefPath(currentMethod);
                        System.Windows.Documents.Hyperlink link = new System.Windows.Documents.Hyperlink();
                        link.Inlines.Add(new System.Windows.Documents.Run(currentMethod.GetDisplayName(false)));
                        link.Tag    = new EntryKey(currentMethod.GetGloballyUniqueId());
                        link.Click += new System.Windows.RoutedEventHandler(LinkHelper.Resolve);

                        Block description = this.GetSummaryFor(xmlComments, currentMethod.Assembly,
                                                               crefPath);

                        members.AddItem(link, description, Model.ElementIconConstants.GetIconPathFor(currentMethod));
                    }
                    this.Blocks.Add(members);
                }

                List <MethodDef> operators = this.representedType.GetOperators();
                if (operators != null && operators.Count > 0)
                {
                    this.Blocks.Add(new Header2("Operators"));
                    members = new SummaryTable();
                    var sortedMethods = from method in operators
                                        orderby method.Name
                                        where !LiveDocumentorFile.Singleton.LiveDocument.IsMemberFiltered(method)
                                        select method;
                    foreach (MethodDef currentMethod in sortedMethods)
                    {
                        crefPath = new CRefPath(currentMethod);
                        System.Windows.Documents.Hyperlink link = new System.Windows.Documents.Hyperlink();
                        link.Inlines.Add(new System.Windows.Documents.Run(currentMethod.GetDisplayName(false)));
                        link.Tag    = new EntryKey(currentMethod.GetGloballyUniqueId());
                        link.Click += new System.Windows.RoutedEventHandler(LinkHelper.Resolve);

                        Block description = this.GetSummaryFor(xmlComments, currentMethod.Assembly,
                                                               crefPath);

                        members.AddItem(link, description, Model.ElementIconConstants.GetIconPathFor(currentMethod));
                    }
                    this.Blocks.Add(members);
                }

                if (this.representedType != null && this.representedType.ExtensionMethods.Count > 0)
                {
                    members = new SummaryTable();

                    var sortedMethods = from method in this.representedType.ExtensionMethods
                                        where !method.IsConstructor
                                        orderby method.Name
                                        where !LiveDocumentorFile.Singleton.LiveDocument.IsMemberFiltered(method)
                                        select method;
                    foreach (MethodDef currentMethod in sortedMethods)
                    {
                        DisplayNameSignitureConvertor      displayNameSig = new DisplayNameSignitureConvertor(currentMethod, false, true, true);
                        System.Windows.Documents.Hyperlink link           = new System.Windows.Documents.Hyperlink();
                        link.Inlines.Add(new System.Windows.Documents.Run(displayNameSig.Convert()));
                        link.Tag    = new EntryKey(currentMethod.GetGloballyUniqueId());
                        link.Click += new System.Windows.RoutedEventHandler(LinkHelper.Resolve);

                        CRefPath path = new CRefPath(currentMethod);

                        Block description = this.GetSummaryFor(xmlComments,
                                                               currentMethod.Assembly,
                                                               path
                                                               );

                        members.AddItem(link, description, Model.ElementIconConstants.GetIconPathFor(currentMethod));
                    }
                    this.Blocks.Add(new Header2("Extension Methods"));
                    this.Blocks.Add(members);
                }

                this.IsGenerated = true;
            }
        }
        public override void Generate()
        {
            if (!this.IsGenerated)
            {
                CRefPath     crefPath     = new CRefPath(_representedType);
                List <Block> parsedBlocks = Elements.Parser.Parse(_representedType.Assembly, _commentsXml, crefPath);

                if (!this._commentsXml.Exists())
                {
                    this.Blocks.Add(new NoXmlComments(_representedType));
                }

                this.Blocks.Add(new Header1(_representedType.GetDisplayName(false) + " Delegate"));

                // Add the summary if it exists
                if (parsedBlocks != null)
                {
                    Block summary = parsedBlocks.Find(currentBlock => currentBlock is Summary);
                    if (summary != null)
                    {
                        this.Blocks.Add(summary);
                    }
                }

                this.AddSyntaxBlock(this._representedType);

                // Add the type parameters if they exist
                if (parsedBlocks != null)
                {
                    List <Block> typeParams = parsedBlocks.FindAll(currentBlock => currentBlock is TypeParamEntry);
                    if (typeParams.Count > 0)
                    {
                        TypeParamSection typeParamSection = new TypeParamSection();
                        foreach (GenericTypeRef genericType in this._representedType.GenericTypes)
                        {
                            string name        = genericType.Name;
                            string description = string.Empty;
                            foreach (TypeParamEntry current in typeParams)
                            {
                                if (current.Param == genericType.Name)
                                {
                                    description = current.Description;
                                }
                            }
                            typeParamSection.AddEntry(new TypeParamEntry(name, description));
                        }
                        this.Blocks.Add(typeParamSection);
                    }
                }

                // Show the delegate parameters, this comes from the invoke method
                // Add the parameter information if available
                MethodDef invokeMethod = this._representedType.GetMethods().Find(m => m.Name == "Invoke");
                this.AddParametersForMethod(invokeMethod, parsedBlocks);

                if (parsedBlocks != null)
                {
                    Block permissions = parsedBlocks.Find(current => current is PermissionList);
                    if (permissions != null)
                    {
                        this.Blocks.Add(permissions);
                    }
                }

                // Add the remarks if it exists
                if (parsedBlocks != null)
                {
                    Block remarks = parsedBlocks.Find(currentBlock => currentBlock is Remarks);
                    if (remarks != null)
                    {
                        this.Blocks.Add(remarks);
                    }
                }

                // Add the example if it exists
                if (parsedBlocks != null)
                {
                    Block summary = parsedBlocks.Find(currentBlock => currentBlock is Example);
                    if (summary != null)
                    {
                        this.Blocks.Add(new Header2("Examples"));
                        this.Blocks.Add(summary);
                    }
                }

                this.AddSeeAlso(parsedBlocks);

                this.IsGenerated = true;
            }
        }
Exemple #14
0
        /// <summary>
        /// Adds the inheritance tree for the specified <paramref name="type"/>.
        /// </summary>
        /// <param name="type">The type to parse and display the tree for.</param>
        protected void AddInheritanceTree(TypeDef type)
        {
            Func <TypeRef, Inline> createLink = delegate(TypeRef forType)
            {
                string  displayName = forType.GetDisplayName(true); // get a default name to display
                TypeDef typeDef     = forType as TypeDef;
                if (typeDef != null)
                {
                    displayName = typeDef.GetDisplayName(true);
                }

                Hyperlink link = new Hyperlink(new Run(displayName));
                if (typeDef == null)
                {
                    CRefPath            parentCrefPath = new CRefPath(forType);
                    Documentation.Entry found          = LiveDocumentorFile.Singleton.LiveDocument.Find(parentCrefPath);
                    if (found != null)
                    {
                        link.Tag = new EntryKey(found.Key);
                    }
                    else
                    {
                        return(new Run(displayName));
                    }
                }
                else
                {
                    link.Tag = new EntryKey(typeDef.GetGloballyUniqueId());
                }
                link.Click += new System.Windows.RoutedEventHandler(LinkHelper.Resolve);
                return(link);
            };

            // Add the inheritance tree
            Elements.List inheritanceList = new Elements.List();
            Elements.List lastList        = inheritanceList;
            if (type.InheritsFrom != null)
            {
                // build a list of parents for the current type
                TypeRef       parent = type.InheritsFrom;
                List <Inline> links  = new List <Inline>();
                while (parent != null)
                {
                    links.Add(createLink(parent));

                    if (parent is TypeDef)
                    {
                        parent = ((TypeDef)parent).InheritsFrom;
                    }
                    else
                    {
                        parent = null;
                    }
                }

                // Reverse the list and build the inheritance tree
                lastList = inheritanceList;
                for (int i = links.Count - 1; i >= 0; i--)
                {
                    lastList.AddListItem(links[i]);
                    if (i > 0)
                    {
                        lastList = lastList.AddChildList(new Elements.List());
                    }
                }
            }

            // add the current type
            lastList = lastList.AddChildList(new Elements.List());
            lastList.AddListItem(type.GetDisplayName(true));

            // add all the derived types
            lastList = lastList.AddChildList(new Elements.List());
            List <TypeRef> derivedTypes = type.GetExtendingTypes();

            derivedTypes.Sort((a, b) => a.GetFullyQualifiedName().CompareTo(b.GetFullyQualifiedName()));
            for (int i = 0; i < derivedTypes.Count; i++)
            {
                Entry forType = LiveDocumentorFile.Singleton.LiveDocument.Find(
                    CRefPath.Create(derivedTypes[i])
                    );
                if (forType != null)
                {
                    lastList.AddListItem(createLink(derivedTypes[i]));
                }
            }

            this.Blocks.Add(new Header2("Inheritance Hierarchy"));
            this.Blocks.Add(inheritanceList);
        }
Exemple #15
0
        public void WhenCRefIsErrorType_ToString_ShouldReturnEmptyString()
        {
            CRefPath path = CRefPath.Parse("invalid string");

            Assert.AreEqual(string.Empty, path.ToString());
        }
        /// <summary>
        /// Generates the page contents
        /// </summary>
        public override void Generate()
        {
            if (!IsGenerated)
            {
                CRefPath     crefPath     = new CRefPath(_method);
                List <Block> parsedBlocks = Elements.Parser.Parse(_method.Assembly, _commentsXml, crefPath);

                if (!_commentsXml.Exists())
                {
                    Blocks.Add(new NoXmlComments(_method));
                }

                Blocks.Add(new Elements.Header1(_method.GetDisplayName(false)));

                // Add the summary if it exists
                if (parsedBlocks != null)
                {
                    Block summary = parsedBlocks.Find(currentBlock => currentBlock is Summary);
                    if (summary != null)
                    {
                        Blocks.Add(summary);
                    }
                }

                AddSyntaxBlock(_method);

                // Add the type parameters if they exist
                if (parsedBlocks != null)
                {
                    List <Block> typeParams = parsedBlocks.FindAll(currentBlock => currentBlock is TypeParamEntry);
                    if (typeParams.Count > 0)
                    {
                        TypeParamSection typeParamSection = new TypeParamSection();
                        foreach (GenericTypeRef genericType in _method.GenericTypes)
                        {
                            string name        = genericType.Name;
                            string description = string.Empty;
                            foreach (TypeParamEntry current in typeParams)
                            {
                                if (current.Param == genericType.Name)
                                {
                                    description = current.Description;
                                }
                            }
                            typeParamSection.AddEntry(new TypeParamEntry(name, description));
                        }
                        Blocks.Add(typeParamSection);
                    }
                }

                AddParametersForMethod(_method, parsedBlocks);
                AddReturnDetails(parsedBlocks);

                // Add the exception table if it exists
                if (parsedBlocks != null)
                {
                    Block exceptions = parsedBlocks.Find(currentBlock => currentBlock is ExceptionList);
                    if (exceptions != null)
                    {
                        Blocks.Add(exceptions);
                    }
                }

                if (parsedBlocks != null)
                {
                    Block permissions = parsedBlocks.Find(current => current is PermissionList);
                    if (permissions != null)
                    {
                        Blocks.Add(permissions);
                    }
                }

                // Add the remarks if it exists
                if (parsedBlocks != null)
                {
                    Block remarks = parsedBlocks.Find(currentBlock => currentBlock is Remarks);
                    if (remarks != null)
                    {
                        Blocks.Add(remarks);
                    }
                }

                // Add the example if it exists
                if (parsedBlocks != null)
                {
                    Block summary = parsedBlocks.Find(currentBlock => currentBlock is Example);
                    if (summary != null)
                    {
                        Blocks.Add(new Header2("Examples"));
                        Blocks.Add(summary);
                    }
                }

                // Add the seealso list if it exists
                AddSeeAlso(parsedBlocks);

                IsGenerated = true;
            }
        }
Exemple #17
0
 public void WhenPassedEmptyString_Parse_ThrowsException()
 {
     Assert.Throws <ArgumentNullException>(delegate() {
         CRefPath.Parse(string.Empty);
     });
 }
        /// <summary>
        /// Outputs the members tables.
        /// </summary>
        private void OutputMembersLists()
        {
            SummaryTable members;
            CRefPath     crefPath;
            List <Block> tempContainer = new List <Block>();

            var constructors = from method in this._representedType.GetConstructors()
                               orderby method.Name
                               where !LiveDocumentorFile.Singleton.LiveDocument.IsMemberFiltered(method)
                               select method;

            if (constructors != null && constructors.Count() > 0)
            {
                tempContainer.Add(new Header2("Constructors"));
                members = new SummaryTable();
                foreach (MethodDef currentMethod in constructors)
                {
                    crefPath = new CRefPath(currentMethod);
                    System.Windows.Documents.Hyperlink link = new System.Windows.Documents.Hyperlink();
                    link.Inlines.Add(new System.Windows.Documents.Run(currentMethod.GetDisplayName(false)));
                    link.Tag    = new EntryKey(currentMethod.GetGloballyUniqueId());
                    link.Click += new System.Windows.RoutedEventHandler(LinkHelper.Resolve);

                    Block description = this.GetSummaryFor(_commentsXml,
                                                           currentMethod.Assembly,
                                                           crefPath);

                    members.AddItem(link, description, Model.ElementIconConstants.GetIconPathFor(currentMethod));
                }
                tempContainer.Add(members);
            }

            var fields = from field in this._representedType.GetFields()
                         orderby field.Name
                         where !LiveDocumentorFile.Singleton.LiveDocument.IsMemberFiltered(field)
                         select field;

            if (fields != null && fields.Count() > 0)
            {
                tempContainer.Add(new Header2("Fields"));
                members = new SummaryTable();
                foreach (FieldDef currentField in fields)
                {
                    crefPath = new CRefPath(currentField);
                    System.Windows.Documents.Hyperlink link = new System.Windows.Documents.Hyperlink();
                    link.Inlines.Add(new System.Windows.Documents.Run(currentField.Name));
                    link.Tag    = new EntryKey(currentField.GetGloballyUniqueId());
                    link.Click += new System.Windows.RoutedEventHandler(LinkHelper.Resolve);

                    Block description = this.GetSummaryFor(_commentsXml,
                                                           currentField.Assembly,
                                                           crefPath);
                    Block value = this.GetSummaryFor(_commentsXml,
                                                     currentField.Assembly,
                                                     crefPath);
                    if (description != null)
                    {
                        members.AddItem(link, description, Model.ElementIconConstants.GetIconPathFor(currentField));
                    }
                    else
                    {
                        members.AddItem(link, value, Model.ElementIconConstants.GetIconPathFor(currentField));
                    }
                }
                tempContainer.Add(members);
            }

            var properties = from property in this._representedType.GetProperties()
                             orderby new DisplayNameSignitureConvertor(property, false, true).Convert()
                             where !LiveDocumentorFile.Singleton.LiveDocument.IsMemberFiltered(property)
                             select property;

            if (properties != null && properties.Count() > 0)
            {
                tempContainer.Add(new Header2("Properties"));
                members = new SummaryTable();
                foreach (PropertyDef currentProperty in properties)
                {
                    crefPath = new CRefPath(currentProperty);
                    System.Windows.Documents.Hyperlink link = new System.Windows.Documents.Hyperlink();
                    link.Inlines.Add(new Run(new DisplayNameSignitureConvertor(currentProperty, false, true).Convert()));
                    link.Tag    = new EntryKey(currentProperty.GetGloballyUniqueId());
                    link.Click += new System.Windows.RoutedEventHandler(LinkHelper.Resolve);

                    Block description = this.GetSummaryFor(_commentsXml, currentProperty.OwningType.Assembly,
                                                           crefPath);
                    members.AddItem(link, description, Model.ElementIconConstants.GetIconPathFor(currentProperty));
                }
                tempContainer.Add(members);
            }

            var events = from c in this._representedType.GetEvents()
                         orderby c.Name
                         where !LiveDocumentorFile.Singleton.LiveDocument.IsMemberFiltered(c)
                         select c;

            if (events != null && events.Count() > 0)
            {
                tempContainer.Add(new Header2("Events"));
                members = new SummaryTable();
                foreach (EventDef currentEvent in events)
                {
                    crefPath = new CRefPath(currentEvent);
                    System.Windows.Documents.Hyperlink link = new System.Windows.Documents.Hyperlink();
                    link.Inlines.Add(new System.Windows.Documents.Run(currentEvent.Name));
                    link.Tag    = new EntryKey(currentEvent.GetGloballyUniqueId());
                    link.Click += new System.Windows.RoutedEventHandler(LinkHelper.Resolve);

                    Block description = this.GetSummaryFor(_commentsXml, currentEvent.Type.Assembly,
                                                           crefPath);
                    members.AddItem(link, description, Model.ElementIconConstants.GetIconPathFor(currentEvent));
                }
                tempContainer.Add(members);
            }

            var methods = from method in this._representedType.GetMethods()
                          orderby method.Name
                          where !LiveDocumentorFile.Singleton.LiveDocument.IsMemberFiltered(method)
                          select method;

            if (methods != null && methods.Count() > 0)
            {
                tempContainer.Add(new Header2("Methods"));
                members = new SummaryTable();
                foreach (MethodDef currentMethod in methods)
                {
                    crefPath = new CRefPath(currentMethod);
                    System.Windows.Documents.Hyperlink link = new System.Windows.Documents.Hyperlink();
                    link.Inlines.Add(new System.Windows.Documents.Run(currentMethod.GetDisplayName(false)));
                    link.Tag    = new EntryKey(currentMethod.GetGloballyUniqueId());
                    link.Click += new System.Windows.RoutedEventHandler(LinkHelper.Resolve);

                    Block description = this.GetSummaryFor(_commentsXml, currentMethod.Assembly,
                                                           crefPath);

                    members.AddItem(link, description, Model.ElementIconConstants.GetIconPathFor(currentMethod));
                }
                tempContainer.Add(members);
            }

            var operators = from method in this._representedType.GetOperators()
                            orderby method.Name
                            where !LiveDocumentorFile.Singleton.LiveDocument.IsMemberFiltered(method)
                            select method;

            if (operators != null && operators.Count() > 0)
            {
                tempContainer.Add(new Header2("Operators"));
                members = new SummaryTable();
                foreach (MethodDef currentMethod in operators)
                {
                    crefPath = new CRefPath(currentMethod);
                    System.Windows.Documents.Hyperlink link = new System.Windows.Documents.Hyperlink();
                    link.Inlines.Add(new System.Windows.Documents.Run(currentMethod.GetDisplayName(false)));
                    link.Tag    = new EntryKey(currentMethod.GetGloballyUniqueId());
                    link.Click += new System.Windows.RoutedEventHandler(LinkHelper.Resolve);

                    Block description = this.GetSummaryFor(_commentsXml, currentMethod.Assembly,
                                                           crefPath);

                    members.AddItem(link, description, Model.ElementIconConstants.GetIconPathFor(currentMethod));
                }
                tempContainer.Add(members);
            }

            if (this._representedType != null && this._representedType.ExtensionMethods.Count > 0)
            {
                members = new SummaryTable();

                var sortedMethods = from method in this._representedType.ExtensionMethods
                                    where !method.IsConstructor
                                    orderby method.Name
                                    where !LiveDocumentorFile.Singleton.LiveDocument.IsMemberFiltered(method)
                                    select method;
                foreach (MethodDef currentMethod in sortedMethods)
                {
                    DisplayNameSignitureConvertor      displayNameSig = new DisplayNameSignitureConvertor(currentMethod, false, true, true);
                    System.Windows.Documents.Hyperlink link           = new System.Windows.Documents.Hyperlink();
                    link.Inlines.Add(new System.Windows.Documents.Run(displayNameSig.Convert()));
                    link.Tag    = new EntryKey(currentMethod.GetGloballyUniqueId());
                    link.Click += new System.Windows.RoutedEventHandler(LinkHelper.Resolve);

                    CRefPath path = new CRefPath(currentMethod);

                    Block description = this.GetSummaryFor(_commentsXml,
                                                           currentMethod.Assembly,
                                                           path
                                                           );

                    members.AddItem(link, description, Model.ElementIconConstants.GetIconPathFor(currentMethod));
                }
                tempContainer.Add(new Header2("Extension Methods"));
                tempContainer.Add(members);
            }

            if (tempContainer.Count > 0)
            {
                this.Blocks.Add(new Paragraph());
                this.Blocks.Add(new Paragraph(new Run(string.Format("The {0} type exposes the following members.", this._representedType.GetDisplayName(false)))));
                this.Blocks.AddRange(tempContainer);
            }
        }
Exemple #19
0
        public override void Render(System.Xml.XmlWriter writer)
        {
            CRefPath       crefPath = new CRefPath(_member);
            XmlCodeComment comment  = _xmlComments.GetComment(crefPath);

            writer.WriteStartElement("member");
            writer.WriteAttributeString("id", this.AssociatedEntry.Key.ToString());
            writer.WriteAttributeString("subId", this.AssociatedEntry.SubKey);
            writer.WriteAttributeString("type", ReflectionHelper.GetType(_member));
            WriteCref(AssociatedEntry, writer);

            writer.WriteStartElement("assembly");
            writer.WriteAttributeString("file", System.IO.Path.GetFileName(_member.Assembly.FileName));
            writer.WriteString(_member.Assembly.Name);
            writer.WriteEndElement();

            string displayName = _member.GetDisplayName(false);

            writer.WriteStartElement("name");
            writer.WriteAttributeString("safename", Exporter.CreateSafeName(displayName));
            writer.WriteString(displayName);
            writer.WriteEndElement();

            writer.WriteStartElement("namespace");
            Entry namespaceEntry = this.AssociatedEntry.FindNamespace(_member.Namespace);

            writer.WriteAttributeString("id", namespaceEntry.Key.ToString());
            writer.WriteAttributeString("name", namespaceEntry.SubKey);
            writer.WriteAttributeString("cref", $"N:{_member.Namespace}");
            writer.WriteString(_member.Namespace);
            writer.WriteEndElement();

            if (_member.IsGeneric)
            {
                RenderGenericTypeParameters(_member.GetGenericTypes(), writer, comment);
            }

            // find and output the summary
            if (comment != XmlCodeComment.Empty)
            {
                XmlCodeElement summary = comment.Elements.Find(currentBlock => currentBlock is SummaryXmlCodeElement);
                if (summary != null)
                {
                    this.Serialize(summary, writer);
                }
            }

            RenderSyntaxBlocks(_member, writer);
            RenderPermissionBlock(_member, writer, comment);

            // find and output the remarks
            if (comment != XmlCodeComment.Empty)
            {
                XmlCodeElement remarks = comment.Elements.Find(currentBlock => currentBlock is RemarksXmlCodeElement);
                if (remarks != null)
                {
                    Serialize(remarks, writer);
                }
            }

            // find and output the examples
            if (comment != XmlCodeComment.Empty)
            {
                XmlCodeElement remarks = comment.Elements.Find(currentBlock => currentBlock is ExampleXmlCodeElement);
                if (remarks != null)
                {
                    Serialize(remarks, writer);
                }
            }

            RenderSeeAlsoBlock(_member, writer, comment);

            if (_member.IsEnumeration)
            {
                writer.WriteStartElement("values");
                List <FieldDef> fields = _member.Fields;
                for (int i = 0; i < fields.Count; i++)
                {
                    if (fields[i].IsSystemGenerated)
                    {
                        continue;
                    }
                    CRefPath       currentPath    = CRefPath.Create(fields[i]);
                    XmlCodeComment currentComment = _xmlComments.GetComment(currentPath);

                    writer.WriteStartElement("value");
                    writer.WriteStartElement("name");
                    writer.WriteString(fields[i].Name);
                    writer.WriteEndElement();
                    writer.WriteStartElement("description");
                    if (currentComment != XmlCodeComment.Empty && currentComment.Elements != null)
                    {
                        XmlCodeElement summary = currentComment.Elements.Find(currentBlock => currentBlock is SummaryXmlCodeElement);
                        if (summary != null)
                        {
                            Serialize(summary, writer);
                        }
                    }
                    writer.WriteEndElement();
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
            }
            else
            {
                if (_member.HasMembers)
                {
                    OutputMembers(writer);
                }
            }

            if (!_member.IsDelegate && !_member.IsEnumeration && !_member.IsInterface && !_member.IsStructure)
            {
                AddInheritanceTree(_member, writer);
            }

            writer.WriteEndElement();   // member
        }
        /// <summary>
        /// Generates the pages contents
        /// </summary>
        public override void Generate()
        {
            if (!this.IsGenerated)
            {
                CRefPath     crefPath     = new CRefPath(this._representedType);
                List <Block> parsedBlocks = Elements.Parser.Parse(this._representedType.Assembly, _commentsXml, crefPath);

                if (!this._commentsXml.Exists())
                {
                    this.Blocks.Add(new NoXmlComments(this._representedType));
                }

                string classType = this._representedType.IsInterface ? " Interface" : " Class";
                this.Blocks.Add(new Header1(this._representedType.GetDisplayName(false) + classType));

                // Add the summary if it exists
                if (parsedBlocks != null)
                {
                    Block summary = parsedBlocks.Find(currentBlock => currentBlock is Summary);
                    if (summary != null)
                    {
                        this.Blocks.Add(summary);
                    }
                }

                if (!this._representedType.IsInterface && !this._representedType.IsStructure)
                {
                    this.AddInheritanceTree(this._representedType);
                }
                this.AddSyntaxBlock(this._representedType);

                // Add the type parameters if they exist
                if (parsedBlocks != null)
                {
                    List <Block> typeParams = parsedBlocks.FindAll(currentBlock => currentBlock is TypeParamEntry);
                    if (typeParams.Count > 0)
                    {
                        TypeParamSection typeParamSection = new TypeParamSection();
                        foreach (GenericTypeRef genericType in this._representedType.GenericTypes)
                        {
                            string name        = genericType.Name;
                            string description = string.Empty;
                            foreach (TypeParamEntry current in typeParams)
                            {
                                if (current.Param == genericType.Name)
                                {
                                    description = current.Description;
                                }
                            }
                            typeParamSection.AddEntry(new TypeParamEntry(name, description));
                        }
                        this.Blocks.Add(typeParamSection);
                    }
                }

                if (parsedBlocks != null)
                {
                    Block permissions = parsedBlocks.Find(current => current is PermissionList);
                    if (permissions != null)
                    {
                        this.Blocks.Add(permissions);
                    }
                }

                this.OutputMembersLists();

                // Add the remarks if it exists
                if (parsedBlocks != null)
                {
                    Block remarks = parsedBlocks.Find(currentBlock => currentBlock is Remarks);
                    if (remarks != null)
                    {
                        this.Blocks.Add(remarks);
                    }
                }

                // Add the example if it exists
                if (parsedBlocks != null)
                {
                    Block summary = parsedBlocks.Find(currentBlock => currentBlock is Example);
                    if (summary != null)
                    {
                        this.Blocks.Add(new Header2("Examples"));
                        this.Blocks.Add(summary);
                    }
                }

                this.AddSeeAlso(parsedBlocks);

                // Inform the application the page has been generated
                this.IsGenerated = true;
            }
        }
        /// <summary>
        /// Generates the pages contents
        /// </summary>
        public override void Generate()
        {
            if (!this.IsGenerated)
            {
                CRefPath     crefPath     = new CRefPath(_field);
                List <Block> parsedBlocks = Elements.Parser.Parse(this._field.Type.Assembly, _xmlComments, crefPath);

                if (!this._xmlComments.Exists())
                {
                    this.Blocks.Add(new NoXmlComments(_field));
                }

                this.Blocks.Add(new Header1(_field.Name));

                // Add the summary if it exists
                if (parsedBlocks != null)
                {
                    Block summary = parsedBlocks.Find(currentBlock => currentBlock is Summary);
                    if (summary != null)
                    {
                        this.Blocks.Add(summary);
                    }
                }

                this.AddSyntaxBlock(this._field);

                // Add the remarks if it exists
                if (parsedBlocks != null)
                {
                    Block value = parsedBlocks.Find(currentBlock => currentBlock is Value);
                    if (value != null)
                    {
                        this.Blocks.Add(value);
                    }
                }

                if (parsedBlocks != null)
                {
                    Block permissions = parsedBlocks.Find(current => current is PermissionList);
                    if (permissions != null)
                    {
                        this.Blocks.Add(permissions);
                    }
                }

                // Add the remarks if it exists
                if (parsedBlocks != null)
                {
                    Block remarks = parsedBlocks.Find(currentBlock => currentBlock is Remarks);
                    if (remarks != null)
                    {
                        this.Blocks.Add(remarks);
                    }
                }

                // Add the example if it exists
                if (parsedBlocks != null)
                {
                    Block summary = parsedBlocks.Find(currentBlock => currentBlock is Example);
                    if (summary != null)
                    {
                        this.Blocks.Add(new Header2("Examples"));
                        this.Blocks.Add(summary);
                    }
                }

                // Add the seealso list if it exists
                this.AddSeeAlso(parsedBlocks);

                this.IsGenerated = true;
            }
        }
        public override void Render(System.Xml.XmlWriter writer)
        {
            CRefPath       crefPath    = new CRefPath(_member);
            XmlCodeComment comment     = _xmlComments.GetComment(crefPath);
            string         displayName = new DisplayNameSignitureConvertor(_member, false, true).Convert();

            writer.WriteStartElement("member");
            writer.WriteAttributeString("id", AssociatedEntry.Key.ToString());
            writer.WriteAttributeString("subId", AssociatedEntry.SubKey);
            writer.WriteAttributeString("type", ReflectionHelper.GetType(_member));
            WriteCref(AssociatedEntry, writer);
            writer.WriteStartElement("name");
            writer.WriteAttributeString("safename", displayName);
            writer.WriteString(displayName);
            writer.WriteEndElement();

            writer.WriteStartElement("namespace");
            Entry namespaceEntry = AssociatedEntry.FindNamespace(_member.OwningType.Namespace);

            writer.WriteAttributeString("id", namespaceEntry.Key.ToString());
            writer.WriteAttributeString("name", namespaceEntry.SubKey);
            writer.WriteAttributeString("cref", $"N:{_member.OwningType.Namespace}");
            writer.WriteString(_member.OwningType.Namespace);
            writer.WriteEndElement();
            writer.WriteStartElement("assembly");
            writer.WriteAttributeString("file", System.IO.Path.GetFileName(_member.Assembly.FileName));
            writer.WriteString(_member.Assembly.Name);
            writer.WriteEndElement();

            // find and output the summary
            if (comment != XmlCodeComment.Empty)
            {
                XmlCodeElement summary = comment.Elements.Find(currentBlock => currentBlock is SummaryXmlCodeElement);
                if (summary != null)
                {
                    Serialize(summary, writer);
                }
            }

            RenderExceptionBlock(_member, writer, comment);
            RenderPermissionBlock(_member, writer, comment);
            RenderSyntaxBlocks(_member, writer);

            MethodDef internalMethod = _member.Getter == null ? _member.Setter : _member.Getter;

            if (_member.IsIndexer() && internalMethod.Parameters.Count > 0)
            {
                writer.WriteStartElement("parameters");
                for (int i = 0; i < internalMethod.Parameters.Count; i++)
                {
                    if (internalMethod.Parameters[i].Sequence == 0)
                    {
                        continue;
                    }

                    TypeRef parameterType = internalMethod.ResolveParameter(internalMethod.Parameters[i].Sequence);
                    TypeDef foundEntry    = _member.Assembly.FindType(parameterType.Namespace, parameterType.Name);

                    writer.WriteStartElement("parameter");
                    writer.WriteAttributeString("name", internalMethod.Parameters[i].Name);
                    writer.WriteStartElement("type");
                    if (foundEntry != null)
                    {
                        writer.WriteAttributeString("key", foundEntry.GetGloballyUniqueId().ToString());
                        writer.WriteAttributeString("cref", CRefPath.Create(foundEntry).ToString());
                    }
                    writer.WriteString(parameterType.GetDisplayName(false));
                    writer.WriteEndElement(); // type

                    if (comment != XmlCodeComment.Empty)
                    {
                        XmlCodeElement paramEntry = comment.Elements.Find(currentBlock =>
                                                                          currentBlock is ParamXmlCodeElement &&
                                                                          ((ParamXmlCodeElement)currentBlock).Name == internalMethod.Parameters[i].Name);
                        if (paramEntry != null)
                        {
                            writer.WriteStartElement("description");
                            ParamXmlCodeElement paraElement = (ParamXmlCodeElement)paramEntry;
                            for (int j = 0; j < paraElement.Elements.Count; j++)
                            {
                                Serialize(paraElement.Elements[j], writer);
                            }
                            writer.WriteEndElement();
                        }
                    }

                    writer.WriteEndElement(); // parameter
                }
                writer.WriteEndElement();
            }

            // find and output the value
            if (comment != XmlCodeComment.Empty)
            {
                XmlCodeElement remarks = comment.Elements.Find(currentBlock => currentBlock is ValueXmlCodeElement);
                if (remarks != null)
                {
                    Serialize(remarks, writer);
                }
            }

            // find and output the remarks
            if (comment != XmlCodeComment.Empty)
            {
                XmlCodeElement remarks = comment.Elements.Find(currentBlock => currentBlock is RemarksXmlCodeElement);
                if (remarks != null)
                {
                    Serialize(remarks, writer);
                }
            }

            // find and output the examples
            if (comment != XmlCodeComment.Empty)
            {
                XmlCodeElement remarks = comment.Elements.Find(currentBlock => currentBlock is ExampleXmlCodeElement);
                if (remarks != null)
                {
                    Serialize(remarks, writer);
                }
            }

            RenderSeeAlsoBlock(_member, writer, comment);

            writer.WriteEndElement();
        }