Пример #1
0
        public static IDictionary <string, DMenu> GetAllMenu(AppType at)
        {
            var dicAllMenu = new Dictionary <string, DMenu>();

            XmlDocument xmlMenu = ReadMenuXmlFile(at);

            XmlNodeList xmlList = xmlMenu.SelectNodes("xml/Model");

            foreach (XmlNode xnModel in xmlList)
            {
                if (xnModel.NodeType == XmlNodeType.Comment)
                {
                    continue;
                }
                DMenu dMenu = NodeToMenu(xnModel, MenuTypeEnum.Modul, string.Empty);
                dicAllMenu[dMenu.Guid] = dMenu;

                foreach (XmlNode xnClass in xnModel.ChildNodes)
                {
                    if (xnClass.NodeType == XmlNodeType.Comment)
                    {
                        continue;
                    }
                    if (xnClass.Name == MenuConfigString.Class)
                    {
                        DMenu dMenuChild = NodeToMenu(xnClass, MenuTypeEnum.Class, dMenu.FullPath);
                        dicAllMenu[dMenuChild.Guid] = dMenuChild;
                        dMenu.ChildMenu.Add(dMenuChild);
                        //增加子菜单分类
                        AddChildMenuClass(xnClass, dMenuChild, dicAllMenu);
                    }
                    else
                    {
                        DMenu dMenuChild = NodeToMenu(xnClass, MenuTypeEnum.Menu, dMenu.FullPath);
                        dicAllMenu[dMenuChild.Guid] = dMenuChild;
                        dMenu.ChildMenu.Add(dMenuChild);
                    }
                }
            }

            return(dicAllMenu);
        }
Пример #2
0
        public static DMenu NodeToMenu(XmlNode xnModel, MenuTypeEnum mte, string parentMenuPath)
        {
            DMenu dMenu = new DMenu();

            dMenu.MenuType    = mte;
            dMenu.Guid        = xnModel.GetAttributeValue(MemuAttrString.Guid);
            dMenu.Name        = xnModel.GetAttributeValue(MemuAttrString.Name);
            dMenu.Code        = xnModel.GetAttributeValue(MemuAttrString.Code);
            dMenu.ShortCutKey = xnModel.GetAttributeValue(MemuAttrString.ShortCutKey);
            dMenu.DLLName     = xnModel.GetAttributeValue(MemuAttrString.DLLName);
            dMenu.FormName    = xnModel.GetAttributeValue(MemuAttrString.FormName);
            if (!string.IsNullOrEmpty(parentMenuPath))
            {
                dMenu.FullPath = parentMenuPath + " > " + dMenu.Name;
            }
            else
            {
                dMenu.FullPath = dMenu.Name;
            }
            return(dMenu);
        }
Пример #3
0
 /// <summary>
 /// 增加子菜单分类
 /// </summary>
 /// <param name="xParentNode"></param>
 /// <param name="dParentMenu"></param>
 /// <param name="allMenu"></param>
 private static void AddChildMenuClass(XmlNode xParentNode, DMenu dParentMenu, IDictionary <string, DMenu> allMenu)
 {
     foreach (XmlNode xnChild in xParentNode.ChildNodes)
     {
         if (xnChild.NodeType == XmlNodeType.Comment)
         {
             continue;
         }
         if (xnChild.Name == MenuConfigString.Class)
         {
             DMenu dMenuChild = NodeToMenu(xnChild, MenuTypeEnum.Class, dParentMenu.FullPath);
             dParentMenu.ChildMenu.Add(dMenuChild);
             allMenu[dMenuChild.Guid] = dMenuChild;
         }
         else
         {
             DMenu dMenuChild = NodeToMenu(xnChild, MenuTypeEnum.Menu, dParentMenu.FullPath);
             dParentMenu.ChildMenu.Add(dMenuChild);
             allMenu[dMenuChild.Guid] = dMenuChild;
         }
     }
 }