public async Task <Errorable <TreeNode[]> > GetTreeNodesAlongPath(TreeTreePath path) { // TODO: test me! List <TreeNode> trnodes = new List <TreeNode>(path.Path.Parts.Count + 1); Errorable <TreeNode> etr; etr = await getTree(path.RootTreeID); if (etr.HasErrors) { return(etr.Errors); } trnodes.Add(etr.Value); for (int i = 0; i < path.Path.Parts.Count; ++i) { TreeTreeReference trrf = etr.Value.Trees.SingleOrDefault(tr => tr.Name == path.Path.Parts[i]); if (trrf == null) { break; } etr = await getTree(trrf.TreeID); if (etr.HasErrors) { return(etr.Errors); } trnodes.Add(etr.Value); } return(trnodes.ToArray()); }
public async Task <Errorable <TreeIDPathMapping> > GetTreeIDByPath(TreeTreePath path) { var treeIDs = await db.ExecuteSingleQueryAsync(new QueryTreeIDsByPaths(path.RootTreeID, path.Path)); if (treeIDs.Count == 0) { return(new TreeIDPathMapping(path, (TreeID?)null)); } return(treeIDs[0]); }
private async Task <Errorable <TreeIDPathMapping> > getTreeIDByPath(TreeTreePath path) { // Get the root Tree: var eroot = await getTree(path.RootTreeID).ConfigureAwait(continueOnCapturedContext: false); if (eroot.HasErrors) { return(eroot.Errors); } TreeNode root = eroot.Value; return(await getTreeIDByPath(root, path)); }
public async Task <Errorable <TreeTree> > GetTreeRecursivelyFromPath(TreeTreePath path) { // Find the TreeID given the path and its root TreeID: var etpm = await getTreeIDByPath(path).ConfigureAwait(continueOnCapturedContext: false); if (etpm.HasErrors) { return(etpm.Errors); } TreeIDPathMapping tpm = etpm.Value; // TODO: TreePathNotFoundError if (!tpm.TreeID.HasValue) { return((TreeTree)null); } // Now use GetTreeRecursively to do the rest: return(await GetTreeRecursively(tpm.TreeID.Value).ConfigureAwait(continueOnCapturedContext: false)); }
public async Task<Errorable<TreeTree>> GetTreeRecursivelyFromPath(TreeTreePath path) { // Find the TreeID given the path and its root TreeID: var etpm = await getTreeIDByPath(path).ConfigureAwait(continueOnCapturedContext: false); if (etpm.HasErrors) return etpm.Errors; TreeIDPathMapping tpm = etpm.Value; // TODO: TreePathNotFoundError if (!tpm.TreeID.HasValue) return (TreeTree)null; // Now use GetTreeRecursively to do the rest: return await GetTreeRecursively(tpm.TreeID.Value).ConfigureAwait(continueOnCapturedContext: false); }
public async Task<Errorable<TreeNode[]>> GetTreeNodesAlongPath(TreeTreePath path) { // TODO: test me! List<TreeNode> trnodes = new List<TreeNode>(path.Path.Parts.Count + 1); Errorable<TreeNode> etr; etr = await getTree(path.RootTreeID); if (etr.HasErrors) return etr.Errors; trnodes.Add(etr.Value); for (int i = 0; i < path.Path.Parts.Count; ++i) { TreeTreeReference trrf = etr.Value.Trees.SingleOrDefault(tr => tr.Name == path.Path.Parts[i]); if (trrf == null) break; etr = await getTree(trrf.TreeID); if (etr.HasErrors) return etr.Errors; trnodes.Add(etr.Value); } return trnodes.ToArray(); }
private async Task<Errorable<TreeIDPathMapping>> getTreeIDByPath(TreeNode root, TreeTreePath path) { ReadOnlyCollection<string> parts = path.Path.Parts; if (parts.Count == 0) return new TreeIDPathMapping(path, path.RootTreeID); int j = 0; // Start descending into child nodes: TreeNode node = root, nextNode; while (node != null) { nextNode = null; // Check all child nodes against the next name in the path: for (int i = 0; i < node.Trees.Length; ++i) // TODO: specific string comparison logic! if (parts[j] == node.Trees[i].Name) { TreeID nextID = node.Trees[i].TreeID; // Run out of path components? This is it! if (++j == parts.Count) return new TreeIDPathMapping(path, (TreeID?)nextID); // Load up the next node so we can scan through its child nodes: var enextNode = await getTree(nextID).ConfigureAwait(continueOnCapturedContext: false); if (enextNode.HasErrors) return enextNode.Errors; nextNode = enextNode.Value; break; } // Attempt to continue: node = nextNode; } // If we got here it means that we didn't find what we were looking for: return new TreeIDPathMapping(path, (TreeID?)null); }
public Task<Errorable<TreeIDPathMapping>> GetTreeIDByPath(TreeTreePath path) { return getTreeIDByPath(path); }
public TreeIDPathMapping(TreeTreePath path, TreeID? id) { this.Path = path; this.TreeID = id; }
private async Task<Errorable<TreeIDPathMapping>> getTreeIDByPath(TreeTreePath path) { // Get the root Tree: var eroot = await getTree(path.RootTreeID).ConfigureAwait(continueOnCapturedContext: false); if (eroot.HasErrors) return eroot.Errors; TreeNode root = eroot.Value; return await getTreeIDByPath(root, path); }
public Task<Errorable<TreeNode[]>> GetTreeNodesAlongPath(TreeTreePath path) { throw new NotImplementedException(); }
public Task <Errorable <TreeTree> > GetTreeRecursivelyFromPath(TreeTreePath path) { return(db.ExecuteSingleQueryAsync(new QueryTreeRecursivelyByPath(path))); }
public Task<Errorable<TreeTree>> GetTreeRecursivelyFromPath(TreeTreePath path) { return db.ExecuteSingleQueryAsync(new QueryTreeRecursivelyByPath(path)); }
public Task <Errorable <TreeIDPathMapping> > GetTreeIDByPath(TreeTreePath path) { return(getTreeIDByPath(path)); }
private async Task <Errorable <TreeIDPathMapping> > getTreeIDByPath(TreeNode root, TreeTreePath path) { ReadOnlyCollection <string> parts = path.Path.Parts; if (parts.Count == 0) { return(new TreeIDPathMapping(path, path.RootTreeID)); } int j = 0; // Start descending into child nodes: TreeNode node = root, nextNode; while (node != null) { nextNode = null; // Check all child nodes against the next name in the path: for (int i = 0; i < node.Trees.Length; ++i) { // TODO: specific string comparison logic! if (parts[j] == node.Trees[i].Name) { TreeID nextID = node.Trees[i].TreeID; // Run out of path components? This is it! if (++j == parts.Count) { return(new TreeIDPathMapping(path, (TreeID?)nextID)); } // Load up the next node so we can scan through its child nodes: var enextNode = await getTree(nextID).ConfigureAwait(continueOnCapturedContext: false); if (enextNode.HasErrors) { return(enextNode.Errors); } nextNode = enextNode.Value; break; } } // Attempt to continue: node = nextNode; } // If we got here it means that we didn't find what we were looking for: return(new TreeIDPathMapping(path, (TreeID?)null)); }
public Task <Errorable <TreeNode[]> > GetTreeNodesAlongPath(TreeTreePath path) { throw new NotImplementedException(); }
public TreeTreePathDoesNotExistError(TreeTreePath path) : base("A tree with path '{0}' does not exist", path) { }
public async Task<Errorable<TreeIDPathMapping>> GetTreeIDByPath(TreeTreePath path) { var treeIDs = await db.ExecuteSingleQueryAsync(new QueryTreeIDsByPaths(path.RootTreeID, path.Path)); if (treeIDs.Count == 0) return new TreeIDPathMapping(path, (TreeID?)null); return treeIDs[0]; }
public QueryTreeByPath(TreeTreePath path) { this._path = path; }
public QueryTreeRecursivelyByPath(TreeTreePath path) { this._path = path; }