using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml.Linq; namespace QMAPP.WinForm.Common { /// /// 读取菜单配置项获取按钮名称 /// public class XmlReader { /// /// 获取按钮名称 /// /// 权限ID列表 /// public List GetMenuBtnFromPower(List powerList) { List menuBtnList = new List(); XDocument doc = XDocument.Load("Menu.xml"); foreach (XElement item in doc.Root.Descendants("PowerInfo"))//得到每一个Person节点,得到这个节点再取他的Name的这个节点的值 { string a = item.Attribute("PowerID").Value.ToString(); FormAuthority auth = new FormAuthority { Form = item.Attribute("FormName") == null ? "" : item.Attribute("FormName").Value, Button = item.Attribute("ButtonName").Value, HasAuthority = false }; if (powerList.Contains(item.Attribute("PowerID").Value)) { auth.HasAuthority = true; menuBtnList.Add(item.Attribute("ButtonName").Value); } ClientContext.AuthList.Add(item.Attribute("PowerID").Value, auth); } return menuBtnList; } } }