/// <summary> /// Extracts as much information from the state of the exception as possible and returns /// it as a formatted string. /// </summary> /// <returns>The formatted exception details.</returns> public string GetExtendedInformation() { StringBuilder builder = new StringBuilder(); if (this.Comment != null) { if (this.Comment == XmlCodeComment.Empty) { builder.AppendLine("The associated XmlCodeComment is equal to Empty"); } else { if (this.Comment.Member != null) { // get the cref path of the member try { builder.AppendLine($"CRef: {this.Comment.Member.ToString()}"); } catch (Exception) { } // if its not null lets just see if we can the base xml for this try { LiveDocumentorFile sf = LiveDocumentorFile.Singleton; if (sf != null && sf.LiveDocument != null) { Documentation.Entry entry = sf.LiveDocument.Find(this.Comment.Member); if (entry != null && entry.XmlCommentFile != null) { ICommentSource commentSource = entry.XmlCommentFile; builder.AppendLine( $"Has XML Comments: {commentSource.Exists()}" ); builder.AppendLine( $"XML: {commentSource.GetXml(this.Comment.Member)}" ); } } } catch (Exception) { } } builder.AppendLine("Formatted Comment"); this.WriteAsText(builder, this.Comment); builder.AppendLine(); } } else { builder.AppendLine("No XmlCodeComment was stored in the exception"); } return(builder.ToString()); }
/// <summary> /// Generates the pages contents. /// </summary> public override void Generate() { if (!IsGenerated) { TypeDef definingType = null; if (_properties != null && _properties.Count > 0) { definingType = (TypeDef)_properties[0].OwningType; } if (!_xmlComments.Exists()) { Blocks.Add(new NoXmlComments(definingType)); } Blocks.Add(new Header1(definingType.GetDisplayName(false) + " Properties")); if (_properties != null && _properties.Count > 0) { SummaryTable methods = new SummaryTable(); var sortedProperties = from property in _properties orderby new DisplayNameSignitureConvertor(property, false, true).Convert() select property; foreach (PropertyDef currentProperty in sortedProperties) { CRefPath path = 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 = GetSummaryFor(_xmlComments, currentProperty.OwningType.Assembly, path); methods.AddItem(link, description, Model.ElementIconConstants.GetIconPathFor(currentProperty)); } this.Blocks.Add(methods); } this.IsGenerated = true; } }
/// <summary> /// Generates the pages contents /// </summary> public override void Generate() { if (!this.IsGenerated) { TypeRef definingType = null; if (_fields.Count > 0) { definingType = _fields[0].Type; } if (!_xmlComments.Exists()) { this.Blocks.Add(new NoXmlComments(definingType)); } this.Blocks.Add(new Header1(definingType.GetDisplayName(false) + " Fields")); if (_fields != null && _fields.Count > 0) { SummaryTable displayedFields = 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 crefPath = new CRefPath(currentField); Hyperlink link = new Hyperlink(); link.Inlines.Add(new Run(currentField.Name)); link.Tag = new EntryKey(currentField.GetGloballyUniqueId()); link.Click += new System.Windows.RoutedEventHandler(LinkHelper.Resolve); Block summary = GetXmlComments(currentField, crefPath); displayedFields.AddItem(link, summary, Model.ElementIconConstants.GetIconPathFor(currentField)); } this.Blocks.Add(displayedFields); } this.IsGenerated = true; } }
/// <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; } }
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; } }
/// <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; } }