private void DumpHelper(SomeNode node, int indentation) { var indentationString = " ".Repeat(indentation); Console.WriteLine($"{indentationString}* {node}"); foreach (var child in node.Children) { DumpHelper(child, indentation + 1); } }
public SomeNode GetOrAddChild(string name) { SomeNode child; if (!TryGetChild(name, out child)) { child = new SomeNode { Parent = this, Name = name }; Children.Add(child); } return child; }
public SomeNode GetOrAddChild(string name) { SomeNode child; if (!TryGetChild(name, out child)) { child = new SomeNode { Parent = this, Name = name }; Children.Add(child); } return(child); }
public int Eval(string args) { var mobs = ReplGlobals.ManagementObjectService.EnumerateManagementObjects(); var root = new SomeNode(); foreach (var mob in mobs) { var breadcrumbs = mob.FullName.Split('.', '/'); var current = root; foreach (var breadcrumb in breadcrumbs) { current = current.GetOrAddChild(breadcrumb); } current.MobDto = mob; } ReplGlobals.Root = root; return 0; }
public int Eval(string args) { var mobs = ReplGlobals.ManagementObjectService.EnumerateManagementObjects(); var root = new SomeNode(); foreach (var mob in mobs) { var breadcrumbs = mob.FullName.Split('.', '/'); var current = root; foreach (var breadcrumb in breadcrumbs) { current = current.GetOrAddChild(breadcrumb); } current.MobDto = mob; } ReplGlobals.Root = root; return(0); }
private static void EvalHelper <T>(SomeNode dataSetNode, DataSetDescriptionDto dataSetDto, bool plotDerivative, Func <DateTime, bool> windowFilter) { var mobNode = dataSetNode.Parent; var mobDto = mobNode.MobDto; var dataSet = ReplGlobals.ManagementObjectService.GetManagedDataSet <T>(mobDto.FullName, dataSetNode.Name); var title = $"{mobDto.FullName}.{dataSetNode.Name}"; if (typeof(T) == typeof(AggregateStatistics <int>)) { var stats = (DataPoint <AggregateStatistics <int> >[])(object) dataSet.DataPoints; var doubleStats = stats.Map(stat => new DataPoint <AggregateStatistics <double> > { Time = stat.Time, Value = new AggregateStatistics <double> { Average = stat.Value.Average, Count = stat.Value.Count, Max = stat.Value.Max, Min = stat.Value.Min, Sum = stat.Value.Sum } }).Where(p => windowFilter(p.Time)).ToArray(); MultiPlot(title, doubleStats, plotDerivative); } else if (typeof(T) == typeof(AggregateStatistics <double>)) { var stats = (DataPoint <AggregateStatistics <double> >[])(object) dataSet.DataPoints; stats = stats.Where(p => windowFilter(p.Time)).ToArray(); MultiPlot(title, stats, plotDerivative); } else { // dataset of ints or doubles var dataPoints = dataSet.DataPoints.Map(p => new PlotPoint { Time = p.Time, Value = Convert.ToDouble(p.Value) }).Where(p => windowFilter(p.Time)).ToArray(); int renderWidth = Console.WindowWidth; int renderHeight = Console.WindowHeight - 8; DrawSinglePlot(title, dataPoints, renderWidth, renderHeight, plotDerivative); } }
public bool TryGetChild(string name, out SomeNode child) { child = Children.FirstOrDefault(c => c.Name == name); return child != null; }
public bool TryGetChild(string name, out SomeNode child) { child = Children.FirstOrDefault(c => c.Name == name); return(child != null); }