示例#1
0
        public virtual PluginBase LoadPlugin(PluginLoadInfo plugin)
        {
            if (this.PluginsLoaded.ContainsKey(plugin.ClassName))
            {
                return(this.PluginsLoaded[plugin.ClassName]);
            }

            Assembly ass = null;

            if (_Assemblies.ContainsKey(plugin.Filename))
            {
                ass = _Assemblies[plugin.Filename];
            }
            else
            {
                string path = Path.Combine(this.AssemblySearchPath, plugin.Filename);

                ass = Assembly.LoadFile(path);

                _Assemblies.Add(plugin.Filename, ass);
            }

            PluginBase plug = (PluginBase)ass.CreateInstance(plugin.ClassName);

            this.PluginsLoaded.Add(plugin.ClassName, plug);

            if (plug.ShowMenuItem)
            {
                AddToPluginsMenu(plug);
            }

            return(plug);
        }
示例#2
0
        public virtual void LoadFromXml(string filename)
        {
            XmlDocument xdoc = new XmlDocument();

            xdoc.Load(filename);

            _ConfigFile = filename;

            XmlNodeList plugins = xdoc.SelectNodes("plugins/plugin");

            if (plugins == null)
            {
                return;
            }

            foreach (XmlNode current in plugins)
            {
                bool   loaded       = bool.Parse(current.Attributes["loaded"].InnerText);
                string plugFileName = current.Attributes["filename"].InnerText;
                string className    = current.Attributes["className"].InnerText;

                PluginLoadInfo plugInfo = new PluginLoadInfo(loaded, plugFileName, className);

                this.Plugins.Add(className, plugInfo);

                if (plugInfo.Loaded)
                {
                    PluginBase plugLoaded = LoadPlugin(plugInfo);
                }
            }
        }