MENU AND OO
Hi,
On my pursuit to improve my OO skills I have decided to try and use OO to build a menu.
Below is the menu class. I have accounted for the URL, Title, ToolTip and if the link should open on a new window or not.
However, I would like to extend this class to so that MenuLink objects had additional properties that determined which users had permission to view certain links but I am not sure how to represent the permissions in my class and also how to link the permission with the users.
Also, this class does not allow for sub menus. Is there a way to use OO to create a menu hierarchy?
Cheers
P
public class MenuLink : MenuItem
{
private string _Url, _Title, _ToolTip;
private bool _IsExternal;
public MenuLink()
{
_Url = "";
_Title = "";
_ToolTip = "";
_IsExternal = false;
}
public MenuLink(string Url, string Title)
{
_Url = Url;
_Title = Title;
_ToolTip = "";
_IsExternal = false;
}
public MenuLink(string Url, string Title, bool IsExternal)
{
_Url = Url;
_Title = Title;
_IsExternal = IsExternal;
_ToolTip = "";
}
public MenuLink(string Url, string Title, string ToolTip, bool IsExternal)
{
_Url = Url;
_Title = Title;
_ToolTip = ToolTip;
_IsExternal = IsExternal;
}
public string Url
{
get { return _Url; }
set { _Url = value; }
}
public string Title
{
get { return _Title; }
set { _Title = value; }
}
public string ToolTip
{
get { return _ToolTip; }
set { _ToolTip = value; }
}
// We need internal and external links.
[XmlAttribute]
public bool IsExternal
{
get { return _IsExternal; }
set { _IsExternal = value; }
}
}
|