/// <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); }
public pathResolverResult resolvePath(String path, pathResolveFlag flags) { pathResolverResult output = this.resolvePathSegments(path, flags); return(output); }