/// <summary> /// Builds the parent score table. /// </summary> /// <param name="node">The node.</param> /// <returns></returns> public static DataTable buildParentScoreTable(this linknodeElement node) { PropertyCollectionExtended pce = node.buildParentScoreCollection(); DataTable dataTable = pce.buildDataTable("Score table"); return(dataTable); }
/// <summary> /// Setnodes the specified path. /// </summary> /// <param name="__path">The path.</param> /// <param name="__name">The name.</param> /// <param name="__parent">The parent.</param> /// <param name="__root">The root.</param> /// <param name="__level">The level.</param> /// <param name="__meta">The meta.</param> public void setnode(string __path, string __name, linknodeElement __parent, linknodeElement __root, int __level) { path = __path; name = __name; parent = __parent; root = __root; level = __level; }
/// <summary> /// Adds the specified path. /// </summary> /// <param name="path">The path.</param> /// <param name="metaObject">The meta object.</param> /// <returns></returns> public linknodeElement Add(string path, object metaObject, int score = 1) { if (sourceNodes.ContainsKey(path)) { if (countExisting) { linknodeElement tmp = sourceNodes[path]; while (tmp != null) { tmp.score++; tmp = tmp.parent; } } else { } } else { if (!path.isNullOrEmpty()) { linknodeElement tmp = root.buildNode(path, metaObject, score); if (!tmp.path.isNullOrEmpty()) { sourceNodes.Add(path, tmp); if (!newpathNodes.ContainsKey(tmp.path)) { newpathNodes.Add(tmp.path, tmp); } sourceNodeList.Add(tmp); tmp.originalPath = path; } else { return(null); } return(tmp); } } return(null); }
/// <summary> /// Builds the parent score collection. /// </summary> /// <param name="node">The node.</param> /// <returns></returns> public static PropertyCollectionExtended buildParentScoreCollection(this linknodeElement node) { PropertyCollectionExtended pce = new PropertyCollectionExtended(); linknodeElement head = node; do { if (head == null) { break; } pce.Add(head.name, head.score, head.name, head.path + " [" + head.level.ToString() + "]"); if (head.parent != null) { head = head.parent; } } while (head.parent != null); return(pce); }
/// <summary> /// Processes the <c>path</c>, builds nodes if missing and adds scores to existing elements. Supplied meta object is attached to the last node /// </summary> /// <param name="root">The root.</param> /// <param name="path">The path.</param> /// <param name="meta">The meta.</param> /// <param name="score">The score.</param> /// <returns></returns> public static linknodeElement buildNode(this linknodeElement root, string path, object meta, int score = 1) { linknodeElement head = root; var ms = regexForPathElements.Matches(path); string repath = ""; int level = 0; foreach (Match m in ms) { if ((m.Value.Length == 0) || (m.Value == PATH_SPLITTER.ToString())) { continue; } level++; string pathPart = m.Value.Trim(PATH_SPLITTER); repath = repath.add(pathPart, PATH_SPLITTER); if (head.items.ContainsKey(pathPart)) { head = head.items[pathPart]; head.score++; } else { linknodeElement tmp = new linknodeElement(); tmp.setnode(repath, pathPart, head, root, level); tmp.score = score; head.items.Add(pathPart, tmp); head = tmp; } } head.setmeta(meta); return(head); }