/// <summary> /// 返回插件说明信息 /// </summary> public Dapper.Model.plugin GetInfo(string dirPath) { Dapper.Model.plugin aboutInfo = new Dapper.Model.plugin(); ///存放关于信息的文件 plugin.config是否存在,不存在返回空串 if (!File.Exists(dirPath + DTKeys.FILE_PLUGIN_XML_CONFING)) { return(aboutInfo); } XmlDocument xml = new XmlDocument(); xml.Load(dirPath + DTKeys.FILE_PLUGIN_XML_CONFING); try { XmlNode root = xml.SelectSingleNode("plugin"); foreach (XmlNode n in root.ChildNodes) { switch (n.Name) { case "directory": aboutInfo.directory = n.InnerText; break; case "name": aboutInfo.name = n.InnerText; break; case "author": aboutInfo.author = n.InnerText; break; case "version": aboutInfo.version = n.InnerText; break; case "description": aboutInfo.description = n.InnerText; break; case "isload": aboutInfo.isload = int.Parse(n.InnerText); break; } } } catch { aboutInfo = new Dapper.Model.plugin(); } return(aboutInfo); }
/// <summary> /// 返回插件列表 /// </summary> public List <Dapper.Model.plugin> GetList(string dirPath) { List <Dapper.Model.plugin> lt = new List <Dapper.Model.plugin>(); DirectoryInfo dirInfo = new DirectoryInfo(dirPath); foreach (DirectoryInfo dir in dirInfo.GetDirectories()) { Dapper.Model.plugin aboutInfo = GetInfo(dir.FullName + @"\"); lt.Add(new Dapper.Model.plugin { directory = aboutInfo.directory, name = aboutInfo.name, author = aboutInfo.author, version = aboutInfo.version, description = aboutInfo.description, isload = aboutInfo.isload }); } return(lt); }