Ejemplo n.º 1
0
        public void LoadPlugins()
        {
            List <Type> pluginTypes = new List <Type>();

            // try to find all plugins
            try
            {
                Type[] types =
                    Lucene.Net.LukeNet.ClassFinder.ClassFinder.GetInstantiableSubtypes(typeof(LukePlugin));
                foreach (Type type in types)
                {
                    pluginTypes.Add(type);
                }
            }
            catch (Exception) { }

            // load plugins declared in the ".plugins" file
            try
            {
                StreamReader reader = new StreamReader(".plugins");
                string       line;
                while ((line = reader.ReadLine()) != null)
                {
                    if (line.StartsWith("#"))
                    {
                        continue;
                    }
                    if (line.Trim().Equals(""))
                    {
                        continue;
                    }

                    Type t = Type.GetType(line, false);
                    if (t.IsSubclassOf(typeof(LukePlugin)) && !pluginTypes.Contains(t))
                    {
                        pluginTypes.Add(t);
                    }
                }
            }
            catch (IOException)
            { }

            foreach (Type pluginType in pluginTypes)
            {
                try
                {
                    LukePlugin plugin = (LukePlugin)pluginType.GetConstructor(new Type[] { }).Invoke(new Object[] { });
                    plugins.Add(plugin);
                }
                catch (Exception)
                { }
            }
            if (plugins.Count == 0)
            {
                return;
            }
            InitPlugins();
        }
Ejemplo n.º 2
0
        private void LoadPluginTab(LukePlugin plugin)
        {
            lblPluginInfo.Text = plugin.GetPluginInfo();
            linkPluginURL.Text = plugin.GetPluginHome();
            linkPluginURL.Links.Clear();
            linkPluginURL.Links.Add(0, linkPluginURL.Text.Length, linkPluginURL.Text);

            plugin.Size = panelPlugin.Size;
            panelPlugin.Controls.Clear();
            panelPlugin.Controls.Add(plugin);
        }