static MomaNode GetNodes(DataRowCollection rows) { MomaNode root = new MomaNode(""); Dictionary <string, MomaNode> namespaces = new Dictionary <string, MomaNode> (); Dictionary <string, MomaNode> types = new Dictionary <string, MomaNode> (); foreach (MomaDataSet.MembersRow row in rows) { string ns; string type; string name; SplitMember(row.Name, out ns, out type, out name); if (type == "BrowserCapabilitiesFactory") { continue; } if (ns == "System.Web.UI.WebControls.WebParts") { continue; } if (ns == "System.Management" || ns == "System.Management.Instrumentation") { continue; } MomaNode nsnode; if (!namespaces.TryGetValue(ns, out nsnode)) { nsnode = new MomaNode(ns); namespaces [ns] = nsnode; root.ChildNodes.Add(nsnode); } MomaNode typenode; if (!types.TryGetValue(ns + type, out typenode)) { typenode = new MomaNode(type); types [ns + type] = typenode; nsnode.ChildNodes.Add(typenode); } MomaNode new_node = new MomaNode(name); new_node.FullName = row.Name; new_node.NumberOfUses = row.Count; if (row.IsTodo) { new_node.Status |= NodeStatus.Todo; } if (row.IsNiex) { new_node.Status |= NodeStatus.Niex; } if (row.IsMissing) { new_node.Status |= NodeStatus.Missing; } typenode.ChildNodes.Add(new_node); } root.SortAndCount(); return(root); }
MomaNode GetRoot() { MomaNode result = HttpRuntime.Cache ["full_nodes@@"] as MomaNode; if (result == null) { result = GetNodes(db.GetTree().Members.Rows); HttpRuntime.Cache.Insert("full_nodes@@", result, null, DateTime.Now.AddMinutes(5), Cache.NoSlidingExpiration); } return(result); }
// // GET: /Tree/ public ActionResult Index(string root) { if (String.IsNullOrEmpty(root)) { return(View(GetRoot())); } MomaNode root_node = GetRoot(); List <object> nodes = GetChildren(root_node, root); return(Json(nodes.ToArray())); }
static List <object> GetChildren(MomaNode root, string node_name) { if (node_name == "source") { return(GetChildrenList(root.ChildNodes, "")); } string [] parts = node_name.Split('-'); MomaNode current = root; for (int i = 0; i < parts.Length; i++) { int idx = Int32.Parse(parts [i]); current = current.ChildNodes [idx]; } return(GetChildrenList(current.ChildNodes, node_name)); }
static MomaNode GetNodes(DataRowCollection rows) { MomaNode root = new MomaNode(""); Dictionary <string, MomaNode> namespaces = new Dictionary <string, MomaNode> (); Dictionary <string, MomaNode> types = new Dictionary <string, MomaNode> (); foreach (MomaDataSet.MembersRow row in rows) { string ns; string type; string name; SplitMember(row.Name, out ns, out type, out name); MomaNode nsnode; if (!namespaces.TryGetValue(ns, out nsnode)) { nsnode = new MomaNode(ns); namespaces [ns] = nsnode; root.ChildNodes.Add(nsnode); } MomaNode typenode; if (!types.TryGetValue(ns + type, out typenode)) { typenode = new MomaNode(type); types [ns + type] = typenode; nsnode.ChildNodes.Add(typenode); } MomaNode new_node = new MomaNode(name); new_node.FullName = row.Name; new_node.NumberOfUses = row.Count; if (row.IsTodo) { new_node.Status |= NodeStatus.Todo; } if (row.IsNiex) { new_node.Status |= NodeStatus.Niex; } if (row.IsMissing) { new_node.Status |= NodeStatus.Missing; } typenode.ChildNodes.Add(new_node); } root.SortAndCount(); return(root); }