Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
 public LoadChildrenResult(DirectoryNodeViewModel node, DirectoryEntry entry)
 {
     Node  = node;
     Entry = entry;
 }