private void AnalyzeAssembly(Assembly assembly) { if (assembly.ReflectionOnly) { return; } IEnumerable <Type> nodeTypes = Enumerable.Empty <Type>(); nodeTypes = assembly.GetTypes(); nodeTypes = nodeTypes.Where(t => !t.IsAbstract && t.IsSubclassOf(typeof(Node)) && t != typeof(Flow) && !t.IsSubclassOf(typeof(Flow))) .Where(t => t.GetConstructor(Type.EmptyTypes) != null); foreach (Type type in nodeTypes) { NodeTypeInfo nodeType = NodeTypeInfo.From(type); NodeCategoryInfo nodeCategory = NodeCategories.FirstOrDefault(c => c.Category == nodeType.Category); if (nodeCategory == null) { NodeCategories.Add(nodeCategory = new NodeCategoryInfo(nodeType.Category)); } nodeCategory.Nodes.Add(nodeType); } }
/// <summary> /// Add a category, given a delimited name /// </summary> /// <param name="categoryName">The comma delimited name </param> /// <returns>The newly created item</returns> public BrowserItem AddCategory(string categoryName) { if (ContainsCategory(categoryName)) { return(GetCategoryByName(categoryName)); } if (!NodeCategories.ContainsKey(categoryName)) { NodeCategories.Add(categoryName, new CategorySearchElement(categoryName)); } // otherwise split the category name var splitCat = SplitCategoryName(categoryName); // attempt to add root element if (splitCat.Count == 1) { return(this.TryAddRootCategory(categoryName)); } // attempt to add root category var currentCat = TryAddRootCategory(splitCat[0]); for (var i = 1; i < splitCat.Count; i++) { currentCat = TryAddChildCategory(currentCat, splitCat[i]); } return(currentCat); }
/// <summary> /// Add a category, given a delimited name /// </summary> /// <param name="categoryName">The comma delimited name </param> /// <returns>The newly created item</returns> internal BrowserItem AddCategory(string categoryName) { if (string.IsNullOrEmpty(categoryName)) { return(this.TryAddRootCategory("Uncategorized")); } if (ContainsCategory(categoryName)) { return(GetCategoryByName(categoryName)); } if (!NodeCategories.ContainsKey(categoryName)) { var cat = new CategorySearchElement(categoryName); cat.Executed += this.OnExecuted; NodeCategories.Add(categoryName, cat); } // otherwise split the category name var splitCat = SplitCategoryName(categoryName); // attempt to add root element if (splitCat.Count == 1) { return(this.TryAddRootCategory(categoryName)); } if (splitCat.Count == 0) { return(null); } // attempt to add root category var currentCat = TryAddRootCategory(splitCat[0]); for (var i = 1; i < splitCat.Count; i++) { currentCat = TryAddChildCategory(currentCat, splitCat[i]); } return(currentCat); }
/// <summary> /// Attempt to add a new category to the browser and an item as one of its children /// </summary> /// <param name="category">The name of the category - a string possibly separated with one period </param> /// <param name="item">The item to add as a child of that category</param> public void TryAddCategoryAndItem(string category, BrowserInternalElement item) { if (!NodeCategories.ContainsKey(category)) { NodeCategories.Add(category, new CategorySearchElement(category)); } var cat = this.AddCategory(category); cat.AddChild(item); item.FullCategoryName = category; var searchEleItem = item as SearchElementBase; if (searchEleItem != null) { _browserLeaves.Add(searchEleItem); } }