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; }
private Tree BuildTree() { var rootDirectory = HostingEnvironment.VirtualPathProvider.GetDirectory("~/Orchard"); var rootNode = new Node("ROOT", NodeType.Directory); rootNode.AddChild(ExpandVirtualNode(rootDirectory)); return new Tree(rootNode); }