private static DocumentedType MapType(ITypeInfo type, XmlDocumentationModel xmlModel)
{
SummaryComment summary = null;
RemarksComment remarks = null;
IEnumerable<ExampleComment> example = null;
// Get the documentation for the type.
var member = xmlModel.Find(type.Identity);
if (member != null)
{
// Get the comments for the type.
summary = member.Comments.OfType<SummaryComment>().Aggregate(
null as SummaryComment,
(prev, curr) => (curr != null && prev != null)
? new SummaryComment(prev.Children.Concat(curr.Children))
: curr ?? prev,
result => result
);
remarks = member.Comments.OfType<RemarksComment>().Aggregate(
null as RemarksComment,
(prev, curr) => (curr != null && prev != null)
? new RemarksComment(prev.Children.Concat(curr.Children))
: curr ?? prev,
result => result
);
example = member.Comments.OfType<ExampleComment>();
}
// Map the methods.
var methods = new List<DocumentedMethod>();
foreach (var method in type.Methods)
{
methods.Add(MapMethod(method, xmlModel));
}
// Map the properties.
var properties = new List<DocumentedProperty>();
foreach (var property in type.Properties)
{
properties.Add(MapProperty(property, xmlModel));
}
// Map the fields.
var fields = new List<DocumentedField>();
foreach (var field in type.Fields)
{
fields.Add(MapField(field, xmlModel));
}
// Return the documented type.
return new DocumentedType(type, properties, methods, fields, summary, remarks, example, type.Metadata);
}