public static List <GroupedTimer> GetParents(GroupedTimer timer, Dictionary <string, GroupedTimer> map, int count = 10) { if (timer == null) { return(new List <GroupedTimer>()); } var result = new List <GroupedTimer>(); var parent = timer; foreach (var i in Enumerable.Range(0, count)) { parent = parent.Info.Parents.Take(1).Select(i => map.Get(i)).FirstOrDefault(); if (parent == null) { break; } result.Add(parent); } return(result); }
public static List <GroupedTimer> GetChildren(GroupedTimer timer, Dictionary <string, GroupedTimer> map, int count = 10) { if (timer == null) { return(new List <GroupedTimer>()); } var result = new List <GroupedTimer>(); var child = timer; result.Add(child); foreach (var i in Enumerable.Range(0, count - 1)) { child = child.Info.Children.Take(1).Select(i => map.Get(i)).FirstOrDefault(); if (child == null) { break; } result.Add(child); } return(result); }