private void RenderReturnsBlock(System.Xml.XmlWriter writer, XmlCodeComment comment) { TypeRef returnTypeRef = _member.GetReturnType(); if (returnTypeRef == WellKnownTypeDef.Void) { return; } writer.WriteStartElement("return"); // write the details of the type and link details if available writer.WriteStartElement("type"); TypeDef foundEntry = _member.Assembly.FindType(returnTypeRef.Namespace, returnTypeRef.Name); writer.WriteAttributeString("name", returnTypeRef.GetDisplayName(false)); if (foundEntry != null) { writer.WriteAttributeString("key", foundEntry.GetGloballyUniqueId().ToString()); writer.WriteAttributeString("cref", CRefPath.Create(foundEntry).ToString()); } writer.WriteEndElement(); // output the returns comment xml element if available if (comment != XmlCodeComment.Empty) { RenderXmlBlock(writer, comment.Elements.Find(currentBlock => currentBlock is ReturnsXmlCodeElement)); } writer.WriteEndElement(); }
private void WriteEntry(System.Xml.XmlWriter writer, ReflectedMember entryMember, string displayName, string type) { CRefPath currentPath = CRefPath.Create(entryMember); XmlCodeComment currentComment = this._xmlComments.GetComment(currentPath); writer.WriteStartElement("entry"); writer.WriteAttributeString("id", entryMember.GetGloballyUniqueId().ToString()); writer.WriteAttributeString("subId", string.Empty); writer.WriteAttributeString("type", type); writer.WriteAttributeString("visibility", ReflectionHelper.GetVisibility(entryMember)); writer.WriteAttributeString("cref", currentPath.ToString()); writer.WriteStartElement("name"); writer.WriteString(displayName); writer.WriteEndElement(); // find and output the summary if (currentComment != XmlCodeComment.Empty && currentComment.Elements != null) { XmlCodeElement summary = currentComment.Elements.Find(currentBlock => currentBlock is SummaryXmlCodeElement); if (summary != null) { Serialize(summary, writer); } } writer.WriteEndElement(); }
// checks if the entry is a ReflectedMember or a namespace and generates the cref attribute // fix: change this so it only outputs when I want it to! protected void WriteCref(Entry entry, System.Xml.XmlWriter writer) { // see DocumentMapper to see how entry.Item is populated if (entry.Item is ReflectedMember && !(entry.Item is AssemblyDef)) { // assemblies cant be cref'd ReflectedMember member = entry.Item as ReflectedMember; CRefPath path = CRefPath.Create(member); writer.WriteAttributeString("cref", path.ToString()); } else if (entry.Item is KeyValuePair <string, List <TypeDef> > ) { // this is a namespace writer.WriteAttributeString("cref", "N:" + ((KeyValuePair <string, List <TypeDef> >)entry.Item).Key); } }
private void RenderParameters(System.Xml.XmlWriter writer, XmlCodeComment comment) { if (_member.Parameters.Count > 0) { writer.WriteStartElement("parameters"); for (int i = 0; i < _member.Parameters.Count; i++) { if (_member.Parameters[i].Sequence == 0) { continue; } TypeRef parameterType = _member.ResolveParameter(_member.Parameters[i].Sequence); TypeDef foundEntry = _member.Assembly.FindType(parameterType.Namespace, parameterType.Name); writer.WriteStartElement("parameter"); writer.WriteAttributeString("name", _member.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 == _member.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(); } }
private void WriteType(int index, List <TypeRef> tree, System.Xml.XmlWriter writer) { if (index < tree.Count) { writer.WriteStartElement("type"); TypeRef current = tree[index]; if (current is TypeDef) { // only provide ids for internal classes writer.WriteAttributeString("id", current.GetGloballyUniqueId().ToString()); writer.WriteAttributeString("cref", CRefPath.Create(current).ToString()); } writer.WriteAttributeString("name", current.GetDisplayName(true)); WriteType(++index, tree, writer); writer.WriteEndElement(); } else if (index == tree.Count) { writer.WriteStartElement("type"); writer.WriteAttributeString("current", "true"); writer.WriteAttributeString("name", _member.GetDisplayName(true)); WriteType(++index, tree, writer); writer.WriteEndElement(); } else if (index > tree.Count) { foreach (TypeRef current in this._member.GetExtendingTypes()) { Entry found = this.Document.Find(CRefPath.Create(current)); if (found != null) { writer.WriteStartElement("type"); if (current is TypeDef) { // only provide ids for internal classes not filtered writer.WriteAttributeString("id", current.GetGloballyUniqueId().ToString()); writer.WriteAttributeString("cref", CRefPath.Create(current).ToString()); } writer.WriteAttributeString("name", current.GetDisplayName(true)); writer.WriteEndElement(); } } } }
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> /// 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); }
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(); }