zoukankan      html  css  js  c++  java
  • 递归菜单简单应用

    /// <summary>
    /// 系统缓存,存放全局变量
    /// </summary>
    public static class Caches
    {
    #region 菜单
    private static List<Feature> m_menu = null;
    public static List<Feature> AllMenu
    {
    get
    {
    if (m_menu.IsNull() || m_menu.Count.Equals(0))
    {
    m_menu = new List<Feature>();
    lock (m_menu)
    {
    if (m_menu.IsNull() || m_menu.Count.Equals(0))
    {
    IList<SysMenu> menuList = NhbHelper.GetCurrentSession().CreateCriteria(typeof(SysMenu))
    .List<SysMenu>();
    GreatMenu(null, m_menu, 0,CBF.WMS.Common.Net.ConvertHelper.IListToList<SysMenu>(menuList));
    }
    }
    }
    return m_menu;
    }
    }

    private static void GreatMenu(object parent, List<Feature> table, int level, List<SysMenu> list)
    {
    Feature feat=null;
    List<SysMenu> tmpMenuList;
    tmpMenuList = list.FindAll(
    delegate(SysMenu menu)
    { return menu.ParentCode ==parent; }
    );

    //list.FindAll(s => s.ParentCode ==parent);

    foreach (SysMenu mdl in tmpMenuList)
    {
    if (parent == mdl.ParentCode)
    {
    feat = new Feature();
    feat.Level = level;
    feat.Id = mdl.Id;
    feat.Name = mdl.Name;
    feat.State = mdl.State;
    feat.Url = mdl.Iconic;
    if (!mdl.ParentCode.IsNull())
    {
    feat.Parent = mdl.ParentCode.Id;
    }
    feat.Pic = "../Icons/folder.png";
    table.Add(feat);
    GreatMenu(mdl, table, level + 1, list);
    }
    }
    }

    public static void ClearMenu()
    {
    m_menu = null;
    }
    #endregion
    }

    注:在904 南丰的CBF.Integration.src.Cash.Caches.cs下面有!

  • 相关阅读:
    2016华为实习编程题:停车管理系统
    lintcode:单词切分
    2016网易实习生编程题:数组中两个数的和等于sum
    2016网易实习生编程题:n个骰子的和等于m
    2016百度编程题:钓鱼比赛
    2016百度编程题:裁减网格纸
    2016百度编程题:罪犯转移
    JAVA面试基础
    扔硬币问题
    随机数生成随机数
  • 原文地址:https://www.cnblogs.com/chengjun/p/5405505.html
Copyright © 2011-2022 走看看