public TreeViewModel BuildCodeMapTree(CodeMapWindowViewModel windowViewModel, bool expandRoots, bool expandChildren, CancellationToken cancellation) { windowViewModel.ThrowOnNull(nameof(windowViewModel)); cancellation.ThrowIfCancellationRequested(); TreeViewModel codeMapTree = CreateEmptyCodeMapTree(windowViewModel); if (codeMapTree == null) { return(null); } cancellation.ThrowIfCancellationRequested(); var roots = CreateRoots(codeMapTree, expandRoots, cancellation)?.Where(root => root != null).ToList(); if (roots.IsNullOrEmpty()) { return(codeMapTree); } cancellation.ThrowIfCancellationRequested(); foreach (TreeNodeViewModel root in roots) { root.AcceptBuilder(this, expandChildren, cancellation); } var rootsToAdd = roots.Where(root => root.Children.Count > 0 || root.DisplayNodeWithoutChildren); codeMapTree.RootItems.AddRange(rootsToAdd); return(codeMapTree); }
public TreeViewModel?BuildCodeMapTree(CodeMapWindowViewModel windowViewModel, bool expandRoots, bool expandChildren, CancellationToken cancellation) { windowViewModel.ThrowOnNull(nameof(windowViewModel)); try { Cancellation = cancellation; return(BuildCodeMapTree(windowViewModel, expandRoots, expandChildren)); } finally { Cancellation = CancellationToken.None; } }