private InheritanceViewModel GetInheritance(DataType dataType) { if (dataType.GetId() == ExportConstants.RootDataTypeId) { return(null); } var ascendants = new List <DataType>(); var currentBaseType = dataType.Base; while (currentBaseType != null) { ascendants.Add(currentBaseType); currentBaseType = currentBaseType.Base; } if (ascendants.Count < 1) { return(null); } var currentChildren = new List <InheritanceNodeViewModel>(); var roots = currentChildren; // Add ancestors in reverse order for (var i = ascendants.Count - 1; i >= 0; i--) { var node = new InheritanceNodeViewModel(ascendants[i].GetUri(), Naming.GetFullIndexTitle(ascendants[i]), new List <InheritanceNodeViewModel>(), true, false, false); currentChildren.Add(node); currentChildren = node.Children; } // Add current node currentChildren.Add(new InheritanceNodeViewModel(dataType.GetUri(), Naming.GetFullIndexTitle(dataType), new List <InheritanceNodeViewModel>(), false, false, true)); // Make sure we only have one root here if (roots.Count != 1) { throw new InvalidOperationException("Unexpected number of roots for " + dataType.GetUri() + ": " + roots.Count); } return(new InheritanceViewModel(roots.First())); }
void BuildTocGroupsFrom(InheritanceNodeViewModel ancestor, Dictionary <string, Tuple <DocumentReferenceViewModel, List <TableOfContentsEntryViewModel> > > entriesByDeclaringType, List <TableOfContentsEntryGroupViewModel> target) { var key = ancestor.Uri; if (entriesByDeclaringType.ContainsKey(key)) { var entryInfo = entriesByDeclaringType[key]; var group = new TableOfContentsEntryGroupViewModel(entryInfo.Item1, entryInfo.Item2); target.Add(group); } // Add groups from descendants foreach (var child in ancestor.Children) { BuildTocGroupsFrom(child, entriesByDeclaringType, target); } }
public InheritanceViewModel(InheritanceNodeViewModel root) { Root = root; HasInheritance = root != null; }