/// <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); }
private void ExecuteElement(CategorySearchElement searchElement) { this.SearchText = searchElement.Name + "."; }