using System; using System.Collections.Generic; using Abp.Application.Navigation; using Abp.Localization; namespace IwbZero.Navigation { /// /// Represents a navigation menu for an application. /// public class IwbMenuDefinition : IIwbHasMenuItemDefinitions { /// /// Unique name of the menu in the application. Required. /// public string Name { get; private set; } /// /// Display name of the menu. Required. /// public string DisplayName { get; set; } /// /// Display name of the menu. Required. /// public ILocalizableString LocalizableDisplayName { get; set; } /// /// Can be used to store a custom object related to this menu. Optional. /// public object CustomData { get; set; } /// /// Menu items (first level). /// public List Items { get; set; } /// /// Creates a new object. /// /// Unique name of the menu /// Display name of the menu /// Display name of the menu /// Can be used to store a custom object related to this menu. public IwbMenuDefinition(string name, string displayName, ILocalizableString localizableDisplayName = null, object customData = null) { if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException("name", "Menu name can not be empty or null."); } Name = name; DisplayName = displayName; LocalizableDisplayName = localizableDisplayName; CustomData = customData; Items = new List(); } /// /// Adds a to . /// /// to be added /// This object public IwbMenuDefinition AddItem(IwbMenuItemDefinition menuItem) { Items.Add(menuItem); return this; } /// /// Remove menu item with given name /// /// public void RemoveItem(string name) { Items.RemoveAll(m => m.Name == name); } } }