/// <summary> /// Initializes this class. /// </summary> /// <param name="assembly"></param> public AssemblyDocumentationReader(Assembly assembly) { _assembly = assembly; _assemblyFilePath = assembly.Location; var assemblyFileName = Path.GetFileNameWithoutExtension(_assemblyFilePath); _assemblyDocumentationFilePath = Path.Combine(Path.GetDirectoryName(_assemblyFilePath), string.Format("{0}.xml", assemblyFileName)); _document = XDocument.Load(_assemblyDocumentationFilePath); _typeDocumenstationsByType = new Dictionary <Type, TypeDocumentation>(); _typeDocumenstationsByName = new Dictionary <string, TypeDocumentation>(); foreach (var member in _document.Descendants("member")) { var name = member.Attribute("name")?.Value ?? string.Empty; if (name.StartsWith("T:")) { var typeDocumentation = TypeDocumentation.CreateFrom(member, assembly); _typeDocumenstationsByName.Add(typeDocumentation.FullTypeName, typeDocumentation); var type = assembly.GetType(typeDocumentation.FullTypeName); if (type != null) { _typeDocumenstationsByType.Add(type, typeDocumentation); } else { Log.WarnFormat("Unable to find type '{0}' in assembly '{1}'", typeDocumentation.FullTypeName, assemblyFileName); } } if (name.StartsWith("P:")) { var propertyDocumentation = PropertyDocumentation.CreateFrom(member, assembly); if (_typeDocumenstationsByName.TryGetValue(propertyDocumentation.FullTypeName, out var typeDocumentation)) { typeDocumentation.Add(propertyDocumentation); } else { Log.WarnFormat("Unable to find type '{0}' in documentation", propertyDocumentation.FullTypeName); } } } }
/// <summary> /// Adds the given property to this type's documentation. /// </summary> /// <param name="property"></param> public void Add(PropertyDocumentation property) { _properties.Add(property); }