public MainWindow()
        {
            InitializeComponent();
            PluginManager manager = new PluginManager();
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("value", 30);
            manager.SetConfiguration(new PluginConfiguration(parameters));
            string runnablePath = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, "..", "..", "..", "..", @"Plugins\Runnable\bin\Debug\Runnable.dll"));
            string wpfPath = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, "..", "..", "..", "..", @"Plugins\WPF\bin\Debug\WPF.dll"));
            manager.LoadPlugin(runnablePath);
            manager.LoadPlugin(wpfPath);
            foreach (LoadedPlugin r in manager.plugins)
            {
                Console.WriteLine(r.Name);
                r.plugin.Started += Plugin_Started;
                r.plugin.Finished += Plugin_Finished;
                if (r.plugin is RunnablePlugin)
                {
                    r.Run();
                }

                if (GenericPlugin.CheckTypeForGenericPlugin(r.PluginType, typeof(WPFPlugin<>)))
                {
                    Type t = GenericPlugin.GetGenericClass(r.PluginType);
                    if (t == typeof(Window))
                    {
                        WPFPlugin<Window> fp = (WPFPlugin<Window>)r.plugin;
                        fp.control = this;
                        fp.Run();
                    }
                }
            }
        }
Esempio n. 2
0
 static void Main(string[] args)
 {
     PluginManager manager = new PluginManager();
     Dictionary<string, object> parameters = new Dictionary<string, object>();
     parameters.Add("value", 30);
     manager.SetConfiguration(new PluginConfiguration(parameters));
     string runnablePath = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, "..", "..", "..", "..", @"Plugins\Runnable\bin\Debug\Runnable.dll"));
     string filePath = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, "..", "..", "..", "..", @"Plugins\File\bin\Debug\File.dll"));
     manager.LoadPlugin(runnablePath);
     manager.LoadPlugin(filePath);
     foreach(LoadedPlugin r in manager.plugins)
     {
         Console.WriteLine(r.Name);
         r.plugin.Started += Plugin_Started;
         r.plugin.Finished += Plugin_Finished;
         if (r.plugin is RunnablePlugin)
         {
             r.Run();
         }
         if (r.plugin is FilePlugin)
         {
             FilePlugin fp = (FilePlugin)r.plugin;
             fp.path = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, "..", "..", "TextFile1.txt")); ;
             fp.Run();
         }
     }
     Console.ReadKey();
 }
Esempio n. 3
0
 private void Form1_Load(object sender, EventArgs e)
 {
     PluginManager manager = new PluginManager();
     Dictionary<string, object> parameters = new Dictionary<string, object>();
     parameters.Add("value", 30);
     manager.SetConfiguration(new PluginConfiguration(parameters));
     //manager.SetKeyAllow(evaluateKey);
     manager.SetKeyAllow((string key) => { return key == "something"; });
     string runnablePath = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, "..", "..", "..", "..", @"Plugins\Runnable\bin\Debug\Runnable.dll"));
     string menuPath = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, "..", "..", "..", "..", @"Plugins\Menu\bin\Debug\Menu.dll"));
     string formPath = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, "..", "..", "..", "..", @"Plugins\Form\bin\Debug\Form.dll"));
     manager.LoadPlugin(runnablePath);
     manager.LoadPlugin(menuPath);
     manager.LoadPlugin(formPath);
     foreach (LoadedPlugin r in manager.plugins)
     {
         Console.WriteLine(r.Name);
         r.plugin.Started += Plugin_Started;
         r.plugin.Finished += Plugin_Finished;
         if (r.plugin is RunnablePlugin)
         {
             r.Run();
         }
         //if (r.plugin is MenuPlugin)
         if(GenericPlugin.CheckTypeForGenericPlugin(r.PluginType, typeof(MenuPlugin)))
         {
             MenuPlugin mp = (MenuPlugin)r.plugin;
             mp.menuStrip = this.formMenuStrip;
             mp.Run();
         }
         if (GenericPlugin.CheckTypeForGenericPlugin(r.PluginType,typeof(FormsPlugin<>)))
         {
             Type t = GenericPlugin.GetGenericClass(r.PluginType);
             if (t == typeof(Form))
             {
                 FormsPlugin<Form> fp = (FormsPlugin<Form>)r.plugin;
                 fp.control = this;
                 fp.Run();
             }
         }
     }
 }