Esempio n. 1
0
    /// <summary>
    /// 获取字典信息
    /// </summary>
    /// <param name="dictionarie">枚举</param>
    public static List <DictionariesEntity> GetDictionaries(DictionariesEnum dictionarie)
    {
        XmlDocument xmldoc = new XmlDocument();

        xmldoc.Load(path);
        XmlNodeList xnl = xmldoc.SelectSingleNode("Dictionaries").ChildNodes;
        List <DictionariesEntity> list = new List <DictionariesEntity>();

        foreach (XmlNode xn in xnl)
        {
            if (xn.Attributes["name"].Value == dictionarie.ToStr())
            {
                XmlNodeList childList = xn.ChildNodes;
                foreach (XmlNode xn2 in childList)
                {
                    DictionariesEntity entity = new DictionariesEntity();
                    entity.ID     = xn2.Attributes["ID"].Value.ToInt();
                    entity.Title  = xn2.InnerText;
                    entity.Remark = xn2.Attributes["Remark"].Value;
                    list.Add(entity);
                }
            }
        }
        return(list);
    }
Esempio n. 2
0
    /// <summary>
    /// 获取字典信息名称
    /// </summary>
    /// <param name="dictionarie"></param>
    /// <returns></returns>
    public static string GetDictionariesTitle(DictionariesEnum dictionarie, int id)
    {
        XmlDocument xmldoc = new XmlDocument();

        xmldoc.Load(path);
        XmlNodeList xnl   = xmldoc.SelectSingleNode("Dictionaries").ChildNodes;
        string      title = "";

        foreach (XmlNode xn in xnl)
        {
            if (xn.Attributes["name"].Value == dictionarie.ToStr())
            {
                XmlNodeList childList = xn.ChildNodes;
                foreach (XmlNode xn2 in childList)
                {
                    if (xn2.Attributes["ID"].Value.ToInt() == id)
                    {
                        title = xn2.InnerText;
                    }
                }
            }
        }
        return(title);
    }