public XmlElement ExtractDocumentationElement(Type type, char prefix, string subElementName) { var fullName = String.IsNullOrEmpty(subElementName) ? prefix + ":" + type.FullName : prefix + ":" + type.FullName + "." + subElementName; fullName = fullName.Replace("..", "."); var xmlDocument = _assemblyXmlDocumentationExtractor.ExtractDocumentation(type.Assembly); var xmlElement = xmlDocument["doc"]; if (xmlElement == null) { throw new XmlException("Invalid XML document. The XML document is missing a <doc> tag."); } var membersElement = xmlElement["members"]; if (membersElement == null) { throw new XmlException("Invalid XML document. The <doc> tag is missing a <members> tag."); } XmlElement matchedElement = null; foreach (var memberElement in membersElement.Cast <XmlElement>().Where(memberElement => memberElement.Attributes["name"].Value.Equals(fullName))) { if (matchedElement != null) { throw new XmlException("Invalid XML document. Multiple elements matched the name value", null); } matchedElement = memberElement; } if (matchedElement == null) { throw new ArgumentException("Could not find documentation for specified element"); } return(matchedElement); }
/// <summary> /// Extract XML documentation for an assembly. /// </summary> /// <param name="assembly">The assembly of interest.</param> /// <returns>XML documentation document.</returns> public XmlDocument ExtractDocumentation(Assembly assembly) { return(_assemblyExtractor.ExtractDocumentation(assembly)); }