/// <summary> /// Sets the value. /// </summary> /// <param name="entityType">Type of the entity.</param> public void SetValue(EntityTypeCache entityType) { ItemId = Constants.None.IdValue; ItemName = Constants.None.TextHtml; if (entityType != null) { ItemId = entityType.Id.ToString(); ItemName = ActionContainer.GetComponentName(entityType.Name); var action = ActionContainer.GetComponent(entityType.Name); if (action != null) { var actionType = action.GetType(); var obj = actionType.GetCustomAttributes(typeof(ActionCategoryAttribute), true).FirstOrDefault(); if (obj != null) { var actionCategory = obj as ActionCategoryAttribute; if (actionCategory != null) { var categoryEntry = ActionContainer.Instance.Categories.Where(c => c.Value == actionCategory.CategoryName).FirstOrDefault(); InitialItemParentIds = categoryEntry.Key.ToString(); } } } } }
public IQueryable <TreeViewItem> GetChildren(string id) { var list = new List <TreeViewItem>(); int?idAsInt = id.AsIntegerOrNull(); if (string.IsNullOrWhiteSpace(id) || (idAsInt.HasValue && idAsInt.Value == 0)) { // Root foreach (var category in ActionContainer.Instance.Categories) { var item = new TreeViewItem(); item.Id = category.Key.ToString(); item.Name = category.Value; item.HasChildren = true; item.IconCssClass = "fa fa-folder"; list.Add(item); } } else { if (idAsInt.HasValue && idAsInt.Value < 0) { // Category if (ActionContainer.Instance.Categories.ContainsKey(idAsInt.Value)) { string categoryName = ActionContainer.Instance.Categories[idAsInt.Value]; var categorizedActions = GetCategorizedActions(); if (categorizedActions.ContainsKey(categoryName)) { foreach (var entityType in categorizedActions[categoryName].OrderBy(e => e.FriendlyName)) { var item = new TreeViewItem(); item.Id = entityType.Id.ToString(); item.Name = ActionContainer.GetComponentName(entityType.Name); item.HasChildren = false; item.IconCssClass = "fa fa-cube"; list.Add(item); } } } } } return(list.OrderBy(i => i.Name).AsQueryable()); }
/// <summary> /// Sets the values. /// </summary> /// <param name="entityTypes">The entity types.</param> /// <exception cref="System.NotSupportedException"></exception> public void SetValues(IEnumerable <EntityTypeCache> entityTypes) { var theEntityTypes = entityTypes.ToList(); if (theEntityTypes.Any()) { var ids = new List <string>(); var names = new List <string>(); var parentIds = new List <string>(); foreach (var entityType in theEntityTypes) { ids.Add(entityType.Id.ToString()); names.Add(ActionContainer.GetComponentName(entityType.Name)); var action = ActionContainer.GetComponent(entityType.Name); if (action != null) { var actionType = action.GetType(); var obj = actionType.GetCustomAttributes(typeof(ActionCategoryAttribute), true).FirstOrDefault(); if (obj != null) { var actionCategory = obj as ActionCategoryAttribute; if (actionCategory != null) { parentIds.Add(string.Format("'{0}'", actionCategory.CategoryName.EscapeQuotes())); } } } } InitialItemParentIds = parentIds.AsDelimited(","); ItemIds = ids; ItemNames = names; } else { ItemId = Constants.None.IdValue; ItemName = Constants.None.TextHtml; } }