-
Notifications
You must be signed in to change notification settings - Fork 0
/
AssemblyDocumentation.cs
35 lines (30 loc) · 1.16 KB
/
AssemblyDocumentation.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace CSharpDocumentation
{
public class AssemblyDocumentation
{
public static AssemblyDocumentation FetchAssemblyDocumentation(Assembly assembly)
{
return new AssemblyDocumentation(assembly);
}
private Dictionary<string, string> namespaceSummaries;
public IEnumerable<string> DocumentedNamespaces { get { return namespaceSummaries.Keys; } }
private AssemblyDocumentation(Assembly assembly)
{
namespaceSummaries = assembly.GetCustomAttributes<NamespaceSummaryAttribute>()
.Where(ns => !string.IsNullOrEmpty(ns.Name) && !string.IsNullOrEmpty(ns.Description))
.ToDictionary(ns => ns.Name, ns => ns.Description);
}
public string GetNamespaceSummary(string targetNamespace)
{
return HasNamespaceSummary(targetNamespace) ? namespaceSummaries[targetNamespace] : null;
}
public bool HasNamespaceSummary(string targetNamespace)
{
return namespaceSummaries.ContainsKey(targetNamespace);
}
}
}