Пример #1
0
            private void SerializeXML(XmlBasePlugin plugin, string dir)
            {
                if (!FileController.Exists(dir + "\\ui.xml"))
                {
                    return;
                }

                try
                {
                    var document = new XmlDocument();
                    document.Load(dir + "\\ui.xml");

                    XmlNode root = document.DocumentElement;
                    XmlNode node = root.ChildNodes[0];

                    var control = new UIControl();
                    control.Component = StringToObjectConverter.StringToComponents(((XmlElement)node).Name);

                    RecursiveSerializeXML(node, control, dir);

                    plugin.Controls.Add(control);
                }
                catch (Exception e)
                {
                    Define.GetLogger().Error("UI Load failed", e);
                }
            }
Пример #2
0
            public XmlBasePluginLoader()
            {
                string[] xmls = FileController.GetLists(Define.PluginDirectory, true);
                foreach (var xml in xmls)
                {
                    if (xml.EndsWith("template"))
                    {
                        continue;
                    }
                    if (!FileController.Exists(xml + "\\plugin.xml"))
                    {
                        continue;
                    }

                    var a = from b in XElement.Load(xml + "\\plugin.xml").Elements()
                            select new XmlBasePlugin
                    {
                        Name        = b.Element("Name").Value,
                        Version     = b.Element("Version").Value,
                        Author      = b.Element("Author").Value,
                        Id          = b.Element("Id").Value,
                        Dependents  = b.Element("Dependents").Value,
                        IconPath    = b.Element("IconPath").Value,
                        Description = b.Element("Description").Value,
                        XmlVersion  = b.Element("XmlVersion").Value
                    };
                    XmlBasePlugin xmlPlugin = null;
                    foreach (var item in a)
                    {
                        xmlPlugin = item;
                    }

                    SerializeXML(xmlPlugin, xml);
                    plugins.Add(xmlPlugin);
                }
            }