Example #1
0
        public CommandCollection <ExtensionCommand> GetNodes()
        {
            var cc = new CommandCollection <ExtensionCommand>();

            foreach (var type in AddinManager.NodesAssembly.GetTypes())
            {
                if (reference != null)
                {
                    foreach (XmlNode child in reference.ChildNodes)
                    {
                        if (child.Name == type.Name)
                        {
                            var ec = new ExtensionCommand
                            {
                                Name      = child.Name,
                                atts      = child.Attributes,
                                reference = child
                            };

                            ec.Ass = AddinManager.NodesAssembly;

                            cc.Add((ExtensionCommand)ec.Populate(type));
                        }
                    }
                }
            }
            return(cc);
        }
Example #2
0
        public CommandCollection<ExtensionCommand> GetNodes()
        {
            var cc = new CommandCollection<ExtensionCommand>();
            foreach (var type in AddinManager.NodesAssembly.GetTypes())
            {
                if (reference != null)
                {
                    foreach (XmlNode child in reference.ChildNodes)
                    {
                        if (child.Name == type.Name)
                        {
                            var ec = new ExtensionCommand
                                     {
                                         Name = child.Name,
                                         atts = child.Attributes,
                                         reference = child
                                     };

                            ec.Ass = AddinManager.NodesAssembly;

                            cc.Add((ExtensionCommand)ec.Populate(type));
                        }
                    }
                }
            }
            return cc;
        }
Example #3
0
        public Addin Read(Assembly ass, string manifest)
        {
            var a = new Addin();

            var xml = new XmlDocument();
            xml.LoadXml(manifest);

            string ns = xml.DocumentElement.NamespaceURI;

            foreach (XmlNode c in xml.FirstChild.ChildNodes)
            {
                if (c.Name == "meta")
                {
                    foreach (XmlNode meta in c.ChildNodes)
                    {
                        switch (meta.Name)
                        {
                            case "author":
                                a.Author = meta.InnerText;
                                break;
                            case "version":
                                a.Version = meta.InnerText;
                                break;
                            case "name":
                                a.Name = meta.InnerText;
                                break;
                            case "icon":
                                a.IconPath = meta.InnerText;
                                break;
                        }
                    }
                }
                else if (c.Name == "extension")
                {
                    var en = new ExtensionNode();
                    en.Path = c.Attributes["path"].Value;

                    foreach (XmlNode cc in c.ChildNodes)
                    {
                        if (cc.Name == "command")
                        {
                            string cls = cc.Attributes["class"].Value.Replace("{namespace}", ns);

                            en.Commands.Add(cls, Activator.CreateInstance(ass.GetType(cls)));
                        }
                        else
                        {
                            var ec = new ExtensionCommand { Name = cc.Name };
                            ec.atts = cc.Attributes;
                            ec.reference = cc;
                            en.Nodes.Add(ec);
                        }
                    }

                    a.ExtensionNodes.Add(en);
                }
                else if (c.Name == "dependencies")
                {
                    foreach (XmlNode dc in c.ChildNodes)
                    {
                        if (dc.Name == "dependency")
                        {
                            if (File.Exists(dc.Attributes["path"].Value))
                            {
                                a.Dependencies.Add(File.ReadAllBytes(dc.Attributes["path"].Value));
                            }
                            else
                            {
                                throw new AddinException(
                                    "Dependency '" + dc.Attributes["path"].Value + "' does not exist!");
                            }
                        }
                    }
                }
            }

            return a;
        }
Example #4
0
        public Addin Read(Assembly ass, string manifest)
        {
            var a = new Addin();

            var xml = new XmlDocument();

            xml.LoadXml(manifest);

            string ns = xml.DocumentElement.NamespaceURI;

            foreach (XmlNode c in xml.FirstChild.ChildNodes)
            {
                if (c.Name == "meta")
                {
                    foreach (XmlNode meta in c.ChildNodes)
                    {
                        switch (meta.Name)
                        {
                        case "author":
                            a.Author = meta.InnerText;
                            break;

                        case "version":
                            a.Version = meta.InnerText;
                            break;

                        case "name":
                            a.Name = meta.InnerText;
                            break;

                        case "icon":
                            a.IconPath = meta.InnerText;
                            break;
                        }
                    }
                }
                else if (c.Name == "extension")
                {
                    var en = new ExtensionNode();
                    en.Path = c.Attributes["path"].Value;

                    foreach (XmlNode cc in c.ChildNodes)
                    {
                        if (cc.Name == "command")
                        {
                            string cls = cc.Attributes["class"].Value.Replace("{namespace}", ns);

                            en.Commands.Add(cls, Activator.CreateInstance(ass.GetType(cls)));
                        }
                        else
                        {
                            var ec = new ExtensionCommand {
                                Name = cc.Name
                            };
                            ec.atts      = cc.Attributes;
                            ec.reference = cc;
                            en.Nodes.Add(ec);
                        }
                    }

                    a.ExtensionNodes.Add(en);
                }
                else if (c.Name == "dependencies")
                {
                    foreach (XmlNode dc in c.ChildNodes)
                    {
                        if (dc.Name == "dependency")
                        {
                            if (File.Exists(dc.Attributes["path"].Value))
                            {
                                a.Dependencies.Add(File.ReadAllBytes(dc.Attributes["path"].Value));
                            }
                            else
                            {
                                throw new AddinException(
                                          "Dependency '" + dc.Attributes["path"].Value + "' does not exist!");
                            }
                        }
                    }
                }
            }

            return(a);
        }