public Rain.Model.plugin GetInfo(string dirPath) { Rain.Model.plugin plugin = new Rain.Model.plugin(); if (!File.Exists(dirPath + "plugin.config")) { return(plugin); } XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(dirPath + "plugin.config"); try { foreach (XmlNode childNode in xmlDocument.SelectSingleNode(nameof(plugin)).ChildNodes) { switch (childNode.Name) { case "directory": plugin.directory = childNode.InnerText; break; case "name": plugin.name = childNode.InnerText; break; case "author": plugin.author = childNode.InnerText; break; case "version": plugin.version = childNode.InnerText; break; case "description": plugin.description = childNode.InnerText; break; case "isload": plugin.isload = int.Parse(childNode.InnerText); break; } } } catch { plugin = new Rain.Model.plugin(); } return(plugin); }
public List <Rain.Model.plugin> GetList(string dirPath) { List <Rain.Model.plugin> pluginList = new List <Rain.Model.plugin>(); foreach (FileSystemInfo directory in new DirectoryInfo(dirPath).GetDirectories()) { Rain.Model.plugin info = this.GetInfo(directory.FullName + "\\"); pluginList.Add(new Rain.Model.plugin() { directory = info.directory, name = info.name, author = info.author, version = info.version, description = info.description, isload = info.isload }); } return(pluginList); }