private DirectoryEntry LoadNewNodeChildren(IDictionary <RelativePath, DirectoryEntry> previouslyLoadedChildren, DirectoryNodeViewModel newParentDirectory) { var directoryEntry = previouslyLoadedChildren.GetValue(new RelativePath(newParentDirectory.RelativePath)); if (directoryEntry == null) { directoryEntry = _nodeViewModelLoader.LoadChildren(newParentDirectory); } return(directoryEntry); }
public DirectoryEntry LoadChildren(DirectoryNodeViewModel node) { var tcs = new TaskCompletionSource <DirectoryEntry>(); var request = new GetDirectoryEntriesRequest { ProjectPath = node.GetProjectPath().Value, DirectoryRelativePath = node.RelativePath }; _typedRequestProcessProxy.RunUnbufferedAsync(request, response => { LoadChildrenCallback(tcs, response); }, response => { LoadChildrenErrorCallback(tcs, response); }); return(tcs.Task.Result); }
private void LoadDirectoryNodeChildren(DirectoryNodeViewModel directoryNode) { if (directoryNode.ChildrenLoaded) { return; } var directoryEntry = _nodeViewModelLoader.LoadChildren(directoryNode); if (directoryEntry == null) { return; } var children = directoryEntry.Entries .Select(childEntry => { var node = IncrementalHierarchyBuilder.CreateNodeViewModel(_nodeTemplateFactory, childEntry, directoryNode); // Initialize template icon if needed if (node is FileNodeViewModel) { if (node.Template.Icon == null) { var extension = PathHelpers.GetExtension(childEntry.Name); Invariants.Assert(extension != null); node.Template.Icon = _imageSourceFactory.GetFileExtensionIcon(extension); } } return(node); }) .ToList(); foreach (var child in children) { child.ItemId = _nodes.MaxItemId + 1; _nodes.AddNode(child); } directoryNode.SetChildren(children); }
public DirectoryEntry LoadChildren(DirectoryNodeViewModel node) { // "fake" root node does not support loading children dynamically (they should have been set manually) if (string.IsNullOrEmpty(node.FullPathString)) { return(null); } var tcs = new TaskCompletionSource <DirectoryEntry>(); var request = new GetDirectoryEntriesRequest { ProjectPath = node.GetProjectPath().Value, DirectoryRelativePath = node.RelativePath }; _typedRequestProcessProxy.RunUnbufferedAsync(request, RunAsyncOptions.Default, response => { LoadChildrenCallback(tcs, response); }, response => { LoadChildrenErrorCallback(tcs, response); }); return(tcs.Task.Result); }
public LoadChildrenResult(DirectoryNodeViewModel node, DirectoryEntry entry) { Node = node; Entry = entry; }