protected override bool CanAdd(IProjectTree target) { return(OrderingHelper.HasValidDisplayOrder(target)); }
protected override async Task <bool> TryHandleCommandAsync(IProjectTree node, bool focused, long commandExecuteOptions, IntPtr variantArgIn, IntPtr variantArgOut) { var nodeToAddTo = GetNodeToAddTo(node); // Publish any existing changes that could potentially be here. // Then call OnAddingNodesAsync. // Then publish changes that could have taken place in OnAddingNodesAsync. await _projectTree.TreeService.PublishLatestTreeAsync(waitForFileSystemUpdates : true).ConfigureAwait(true); await OnAddingNodesAsync(nodeToAddTo).ConfigureAwait(true); await _projectTree.TreeService.PublishLatestTreeAsync(waitForFileSystemUpdates : true).ConfigureAwait(true); // Get the difference to see what was added. // We do a sanity check to make sure they have a valid display order. // We also order the added nodes by their display order. var updatedNode = _projectTree.CurrentTree.Find(node.Identity); var updatedNodeToAddTo = _projectTree.CurrentTree.Find(nodeToAddTo.Identity); var addedNodes = updatedNodeToAddTo.Children.Where(x => !nodeToAddTo.TryFind(x.Identity, out var subtree) && OrderingHelper.HasValidDisplayOrder(x)) .OrderBy(OrderingHelper.GetDisplayOrder).ToList(); if (addedNodes.Any()) { await OnAddedNodesAsync(_projectVsServices.ActiveConfiguredProject, addedNodes, updatedNode).ConfigureAwait(true); } return(true); }