using System.Collections.Generic; using Abp.Application.Features; using Abp.Authorization; using Abp.Collections.Extensions; using Abp.Localization; using System; namespace Abp.Application.Navigation { /// /// Represents an item in a . /// public class MenuItemDefinition : IHasMenuItemDefinitions { /// /// Unique name of the menu item in the application. /// Can be used to find this menu item later. /// public string Name { get; } /// /// Display name of the menu item. Required. /// public ILocalizableString DisplayName { get; set; } /// /// The Display order of the menu. Optional. /// public int Order { get; set; } /// /// Icon of the menu item if exists. Optional. /// public string Icon { get; set; } /// /// The URL to navigate when this menu item is selected. Optional. /// public string Url { get; set; } /// /// A permission name. Only users that has this permission can see this menu item. /// Optional. /// [Obsolete("Use PermissionDependency instead.")] public string RequiredPermissionName { get; set; } /// /// A permission dependency. Only users that can satisfy this permission dependency can see this menu item. /// Optional. /// public IPermissionDependency PermissionDependency { get; set; } /// /// A feature dependency. /// Optional. /// public IFeatureDependency FeatureDependency { get; set; } /// /// This can be set to true if only authenticated users should see this menu item. /// public bool RequiresAuthentication { get; set; } /// /// Returns true if this menu item has no child . /// public bool IsLeaf => Items.IsNullOrEmpty(); /// /// Target of the menu item. Can be "_blank", "_self", "_parent", "_top" or a frame name. /// public string Target { get; set; } /// /// Can be used to store a custom object related to this menu item. Optional. /// public object CustomData { get; set; } /// /// Can be used to enable/disable a menu item. /// public bool IsEnabled { get; set; } /// /// Can be used to show/hide a menu item. /// public bool IsVisible { get; set; } /// /// Sub items of this menu item. Optional. /// public virtual List Items { get; } /// /// /// /// /// /// This parameter is obsolete. Use instead! /// /// /// /// /// /// /// public MenuItemDefinition( string name, ILocalizableString displayName, string icon = null, string url = null, bool requiresAuthentication = false, string requiredPermissionName = null, int order = 0, object customData = null, IFeatureDependency featureDependency = null, string target = null, bool isEnabled = true, bool isVisible = true, IPermissionDependency permissionDependency = null) { Check.NotNull(name, nameof(name)); Check.NotNull(displayName, nameof(displayName)); Name = name; DisplayName = displayName; Icon = icon; Url = url; RequiresAuthentication = requiresAuthentication; RequiredPermissionName = requiredPermissionName; Order = order; CustomData = customData; FeatureDependency = featureDependency; Target = target; IsEnabled = isEnabled; IsVisible = isVisible; PermissionDependency = permissionDependency; Items = new List(); } /// /// Adds a to . /// /// to be added /// This object public MenuItemDefinition AddItem(MenuItemDefinition menuItem) { Items.Add(menuItem); return this; } /// /// Remove notification with given name /// /// public void RemoveItem(string name) { Items.RemoveAll(m => m.Name == name); } } }