public CalculationBrowser() { _availableCalculations = new List <Calculation>(); _root = new BrowserInfo("Calculations"); foreach (Assembly assems in AppDomain.CurrentDomain.GetAssemblies()) { foreach (Type type in assems.GetTypes().Where(t => t.IsClass && !t.IsAbstract && t.IsSubclassOf(typeof(Calculation)))) { if (!type.IsDefined(typeof(HiddenCalculationAttribute), false)) { _availableCalculations.Add((Calculation)Activator.CreateInstance(type)); } } } BuildTree(); }
private void RecursiveAdd(Queue <string> path, BrowserInfo parent, Calculation calc) { if (path.Count > 1) { string childId = path.Dequeue(); BrowserInfo child = parent.Children.FirstOrDefault(bi => bi.Name == childId); if (child == null) { child = new BrowserInfo(childId); parent._children.Add(child); } RecursiveAdd(path, child, calc); } else { CalculationInfo info = new CalculationInfo(calc); parent._children.Add(info); } }