1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using MECF.Framework.Common.Account.Extends;
- namespace OpenSEMI.ClientBase
- {
- public class MenuManager
- {
- public List<AppMenu> MenuItems { get; private set; }
- #region Operation
- public void LoadMenu(List<AppMenu> menuitems)
- {
- foreach (AppMenu menuitem in menuitems)
- {
- if (menuitem.MenuItems != null)
- {
- for (int i = menuitem.MenuItems.Count - 1; i >= 0; i--)
- {
- var submenuitem = menuitem.MenuItems[i];
- submenuitem.Parent = menuitem;
- if (submenuitem.Permission == 1) //remove menu if permission is "None"
- menuitem.MenuItems.Remove(submenuitem);
- }
- }
- }
- this.MenuItems = menuitems;
- }
- public void FilterMenus(List<string> pSystems)
- {
- if (pSystems == null || this.MenuItems == null)
- return;
- foreach (AppMenu menuitem in this.MenuItems)
- {
- if (menuitem.MenuItems != null)
- {
- for (int i = menuitem.MenuItems.Count - 1; i >= 0; i--)
- {
- var submenuitem = menuitem.MenuItems[i];
- //filter
- }
- }
- }
- }
- private bool IsExist(List<string> pSource, string pMatch)
- {
- foreach (var item in pSource)
- {
- if (pMatch.IndexOf(item) >= 0)
- return true;
- }
- return false;
- }
- public List<AppMenu> GetAllClone()
- {
- if (this.MenuItems == null)
- return null;
- List<AppMenu> cloneList = new List<AppMenu>();
- foreach (var item in this.MenuItems)
- {
- cloneList.Add((AppMenu)item.Clone(item.Parent));
- }
- return cloneList;
- }
- #endregion
- }
- }
|