public DataTypeViewModel(DocumentIdViewModel id, DocumentUriViewModel uri, TitlesViewModel titlesViewModel, SyntaxViewModel syntaxViewModel, DocumentReferenceViewModel @base, LocationViewModel location, InheritanceViewModel inheritance, ParametersViewModel parameters, ReturnsViewModel returns, UxClassPropertiesViewModel uxProperties, ValuesViewModel values, CommentViewModel comment, DocumentReferenceViewModel declaredIn, ImplementedInterfacesViewModel implementedInterfaces, AttributesViewModel attributes, IEntity underlyingEntity) : base(id, uri, titlesViewModel, syntaxViewModel, comment, declaredIn, underlyingEntity) { Base = @base; Location = location; Inheritance = inheritance; Parameters = parameters; Returns = returns; UxProperties = uxProperties; Values = values; ImplementedInterfaces = implementedInterfaces; Attributes = attributes; }
List <TableOfContentsEntryGroupViewModel> GroupByAncestry(InheritanceViewModel inheritance, List <TableOfContentsEntryViewModel> entries, bool isAttached) { // If there is no inheritance, just return an empty group if (inheritance == null) { return(entries.Count == 0 ? new List <TableOfContentsEntryGroupViewModel>() : new List <TableOfContentsEntryGroupViewModel> { new TableOfContentsEntryGroupViewModel(null, entries) }); } var rootGroupItems = new List <TableOfContentsEntryViewModel>(); // Build a cache var entriesByDeclaringType = new Dictionary <string, Tuple <DocumentReferenceViewModel, List <TableOfContentsEntryViewModel> > >(); foreach (var entry in entries) { if (isAttached) { if (entry.Parameters == null || entry.Parameters.Count < 1) { throw new ArgumentException($"Found attached member without required amount of parameters: {entry.Id.Id}"); } rootGroupItems.Add(entry); } else { if (entry.DeclaredIn == null) { rootGroupItems.Add(entry); } else { if (!entriesByDeclaringType.ContainsKey(entry.DeclaredIn.Id.Id)) { entriesByDeclaringType.Add(entry.DeclaredIn.Id.Id, new Tuple <DocumentReferenceViewModel, List <TableOfContentsEntryViewModel> >(entry.DeclaredIn, new List <TableOfContentsEntryViewModel>())); } entriesByDeclaringType[entry.DeclaredIn.Id.Id].Item2.Add(entry); } } } var groups = new List <TableOfContentsEntryGroupViewModel>(); BuildTocGroupsFrom(inheritance.Root, entriesByDeclaringType, groups); groups.Reverse(); // Get the closest ancestors first in the list // If we have root items, add them first if (rootGroupItems.Any()) { groups.Insert(0, new TableOfContentsEntryGroupViewModel(null, rootGroupItems)); } return(groups); }