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