/// <summary> /// Tests the node. /// </summary> /// <param name="node">The node.</param> /// <param name="flags">The flags.</param> /// <param name="types">The types.</param> /// <returns></returns> internal static Boolean testNode(this imbTreeNode node, imbTreeQueryFlag flag, imbTreeNodeType types) { var flags = flag.getEnumListFromFlags <imbTreeQueryFlag>(); if (flags.Contains(imbTreeQueryFlag.collectAll)) { return(true); } if (node is imbTreeNodeLeaf) { if (flags.ContainsOneOrMore(imbTreeQueryFlag.collectAllLeafs)) { return(true); } } else { if (flags.ContainsOneOrMore(imbTreeQueryFlag.collectAllBranches)) { return(true); } } if (flags.Contains(imbTreeQueryFlag.collectAllOfNodeType)) { return(types.HasFlag(node.nodeType())); } return(false); }
public void Add(imbTreeNode child) { child.parent = this as imbTreeNodeBranch; base.Add(child.name, child); }
/// <summary> /// Pravi novu granu - ili strukturu pod grana -- ako je prosledjena putanja umesto obicnog imena /// </summary> /// <param name="branchName"></param> /// <returns></returns> public imbTreeNodeBranch AddNewBranch(String branchNameOrPath, ITextRender report = null) { sourcePath = branchNameOrPath; pathResolverResult query = this.resolvePath(branchNameOrPath, pathResolveFlag.autorenameCollectionIndexer); imbTreeNodeBranch head = null; switch (query.type) { case pathResolverResultType.foundOne: case pathResolverResultType.foundMany: //head = query.nodeFound. as imbTreeNodeBranch; head = query.nodeFound.imbFirstSafe() as imbTreeNodeBranch; /* * Exception ex = new aceGeneralException("Branch is already found at: " + branchNameOrPath); * * var isb = new imbStringBuilder(0); * isb.AppendLine("Can't add new branch on place where the one already exists error"); * isb.AppendPair("Target is: ", this.toStringSafe()); * devNoteManager.note(this, ex, isb.ToString(), "Can't add new branch on place where the one already exists", devNoteType.unknown); */ break; default: case pathResolverResultType.nothingFound: case pathResolverResultType.folderFoundButItemMissing: case pathResolverResultType.folderFoundButFoldersMissing: imbTreeNode nd = query.nodeFound.imbFirstSafe() as imbTreeNode; if (nd is imbTreeNodeLeaf) { head = nd.parent; imbTreeNodeBranch newBranch = new imbTreeNodeBranch(nd.name); newBranch.learnFrom(nd); head.Remove(nd.keyHash); head.Add(newBranch); head = newBranch; if (report != null) { //report.AppendPair("replacing existing Leaf node with branch one", head.name); } } else { head = nd as imbTreeNodeBranch; } if (head == null) { head = this; } foreach (pathSegment ps in query.missing) { imbTreeNodeBranch newBranch = new imbTreeNodeBranch(ps.needle); head.Add(newBranch); if (report != null) { //report.AppendPair("Add new node to [" + head.path + "] : ", newBranch.name); } head = newBranch; } break; } return(head); }