private Node ExpandVirtualNode(VirtualFileBase virtualNode)
        {
            if (!virtualNode.IsDirectory) return new Node(virtualNode.Name, NodeType.File);

            var node = new Node(virtualNode.Name, NodeType.Directory);

            var virtualDirectory = (VirtualDirectory)virtualNode;
            foreach (var child in virtualDirectory.Directories.Cast<VirtualFileBase>().Union(virtualDirectory.Files.Cast<VirtualFileBase>()))
            {
                // Excluding common folders that are unnecessary to process, the easy way. May need to be configurable.
                if (child.Name == ".hg" || child.Name == ".git") continue;

                node.AddChild(ExpandVirtualNode(child));
            }

            return node;
        }
 public void AddChild(Node node)
 {
     // The virtual file system, that is mimicked here, is case-insensitive, so normalizing the name.
     _children[node.Name.ToLowerInvariant()] = node;
 }
 private Tree BuildTree()
 {
     var rootDirectory = HostingEnvironment.VirtualPathProvider.GetDirectory("~/Orchard");
     var rootNode = new Node("ROOT", NodeType.Directory);
     rootNode.AddChild(ExpandVirtualNode(rootDirectory));
     return new Tree(rootNode);
 }
 public Tree(Node root)
 {
     _root = root;
 }