Example #1
0
        private void tvwPlugins_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
        {
            //Make sure there's a selected Plugin
            if (this.tvwPlugins.SelectedNode != null)
            {
                //Get the selected Plugin
                Types.AvailablePlugin selectedPlugin = Global.Plugins.AvailablePlugins.Find(tvwPlugins.SelectedNode.Text.ToString());

                if (selectedPlugin != null)
                {
                    //Again, if the plugin is found, do some work...


                    //This part adds the plugin's info to the 'Plugin Information:' Frame
                    this.lblPluginName.Text    = selectedPlugin.Instance.Name;
                    this.lblPluginVersion.Text = "(" + selectedPlugin.Instance.Version + ")";
                    this.lblPluginAuthor.Text  = "By: " + selectedPlugin.Instance.Author;
                    this.lblPluginDesc.Text    = selectedPlugin.Instance.Description;

                    //Clear the current panel of any other plugin controls...
                    //Note: this only affects visuals.. doesn't close the instance of the plugin
                    this.pnlPlugin.Controls.Clear();

                    //Set the dockstyle of the plugin to fill, to fill up the space provided
                    selectedPlugin.Instance.MainInterface.Dock = DockStyle.Fill;

                    //Finally, add the usercontrol to the panel... Tadah!
                    this.pnlPlugin.Controls.Add(selectedPlugin.Instance.MainInterface);
                }
            }
        }
        public void RegisterInternalPLugin(Type type)
        {
            Types.AvailablePlugin newPlugin = new Types.AvailablePlugin(type);

            //Add the new plugin to our collection here
            this.colAvailablePlugins.Add(newPlugin);
        }
Example #3
0
        private void AddPlugin(string FileName)
        {
            Assembly pluginAssembly = Assembly.LoadFrom(FileName);

            foreach (Type pluginType in pluginAssembly.GetTypes())
            {
                if (pluginType.IsPublic)
                {
                    if (!pluginType.IsAbstract)
                    {
                        if (pluginType.IsSubclassOf(typeof(IPlugin)))
                        {
                            Types.AvailablePlugin newPlugin = new Types.AvailablePlugin();
                            newPlugin.AssemblyPath = FileName;
                            newPlugin.Type         = pluginAssembly.GetType(pluginType.ToString());
                            if (FiddlerControls.Options.PluginsToLoad.Contains(pluginType.ToString()))
                            {
                                newPlugin.CreateInstance();
                                newPlugin.Instance.Host = this;
                                newPlugin.Instance.Initialize();
                            }
                            this.colAvailablePlugins.Add(newPlugin);
                            newPlugin = null;
                        }
                    }
                }
            }
            pluginAssembly = null;
        }
        /*/// <summary>
         * /// Unloads and Closes all AvailablePlugins
         * /// </summary>
         * public void ClosePlugins()
         * {
         *      foreach (Types.AvailablePlugin pluginOn in colAvailablePlugins)
         *      {
         *              //Close all plugin instances
         *              //We call the plugins Dispose sub first incase it has to do
         *              //Its own cleanup stuff
         *
         *              //After we give the plugin a chance to tidy up, get rid of it
         *              pluginOn.Instance = null;
         *      }
         *
         *      //Finally, clear our collection of available plugins
         *      colAvailablePlugins.Clear();
         * }*/
        private void AddPlugin(string FileName)
        {
            //Create a new assembly from the plugin file we're adding..
            Assembly pluginAssembly = Assembly.LoadFrom(FileName);

            try {
                //Next we'll loop through all the Types found in the assembly
                foreach (Type pluginType in pluginAssembly.GetTypes())
                {
                    if (pluginType.IsPublic)                       //Only look at public types
                    {
                        if (!pluginType.IsAbstract)                //Only look at non-abstract types
                        //Gets a type object of the interface we need the plugins to match
                        {
                            Type typeInterface = pluginType.GetInterface("DE.API.PanelElement", true);

                            //Make sure the interface we want to use actually exists
                            if (typeInterface != null)
                            {
                                //Create a new available plugin since the type implements the PanelElement interface
                                Types.AvailablePlugin newPlugin = new Types.AvailablePlugin(pluginAssembly.GetType(pluginType.ToString()));

                                //Add the new plugin to our collection here
                                this.colAvailablePlugins.Add(newPlugin);

                                return;
                            }
                        }
                    }
                }
            } catch (ReflectionTypeLoadException ex) {
                MessageBox.Show(ex.LoaderExceptions[0].ToString());
            }
            MessageBox.Show("Not a plugin: " + FileName);
        }
Example #5
0
 private void typesComboBox_DropDownClosed(object sender, System.EventArgs e)
 {
     if (typesComboBox.Text != "")
     {
         if (CntrlPnl.Children.Count > 0)
         {
             CntrlPnl.Children.RemoveAt(0);
         }
         Types.AvailablePlugin selectedPlugin = GlobalUserControls.OSAEUserControls.AvailablePlugins.Find(typesComboBox.Text.ToString());
         PluginName.Content    = selectedPlugin.Instance.Name;
         PluginDesc.Content    = selectedPlugin.Instance.Description;
         PluginVersion.Content = selectedPlugin.Instance.Version;
         PluginAuthor.Content  = selectedPlugin.Instance.Author;
         int    lastslash = selectedPlugin.AssemblyPath.ToString().LastIndexOf(@"\");
         string imgURI    = selectedPlugin.AssemblyPath.ToString().Substring(0, lastslash + 1);
         imgURI = imgURI + "ScreenShot.jpg";
         System.Windows.Media.Imaging.BitmapImage pluginImg = new System.Windows.Media.Imaging.BitmapImage();
         pluginImg.BeginInit();
         pluginImg.UriSource = new System.Uri(imgURI);
         pluginImg.EndInit();
         PluginImg.Source = pluginImg;
         selectedPlugin.Instance.InitializeAddCtrl(currentScreen, selectedPlugin.Instance.Name, currentUser);
         UserControl addcontrol = selectedPlugin.Instance.CtrlInterface;
         if (addcontrol.Height > CntrlPnl.Height)
         {
             double cH = addcontrol.Height - CntrlPnl.Height;
             this.Height     = this.Height + cH + 80;
             CntrlPnl.Height = addcontrol.Height + 80;
         }
         CntrlPnl.Children.Add(addcontrol);
     }
 }
Example #6
0
 /**
  * Adds a plugin to the plugin collection
  */
 private void AddPlugin(string fileName)
 {
     try
     {
         Assembly pluginAssembly = Assembly.LoadFrom(fileName);
         foreach (Type pluginType in pluginAssembly.GetTypes())
         {
             if (pluginType.IsPublic)
             {
                 if (!pluginType.IsAbstract)
                 {
                     Type typeInterface = pluginType.GetInterface("PluginCore.IPlugin", true);
                     if (typeInterface != null)
                     {
                         Types.AvailablePlugin newPlugin = new Types.AvailablePlugin();
                         newPlugin.AssemblyPath  = fileName;
                         newPlugin.Instance      = (IPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
                         newPlugin.Instance.Host = this;
                         newPlugin.Instance.Initialize();
                         this.colAvailablePlugins.Add(newPlugin);
                         newPlugin = null;
                     }
                     typeInterface = null;
                 }
             }
         }
         pluginAssembly = null;
     }
     catch (Exception ex)
     {
         ErrorHandler.AddToLog(ex);
     }
 }
        private void AddPlugin(string FileName)
        {
            try
            {
                //Create a new assembly from the plugin file we're adding..
                Assembly pluginAssembly = Assembly.Load(File.ReadAllBytes(FileName));

                //Next we'll loop through all the Types found in the assembly
                foreach (Type pluginType in pluginAssembly.GetTypes())
                {
                    if (pluginType.IsPublic)        //Only look at public types
                    {
                        if (!pluginType.IsAbstract) //Only look at non-abstract types
                        {
                            //Gets a type object of the interface we need the plugins to match
                            Type typeInterface = pluginType.GetInterface("PluginInterface.IPlugin", true);

                            //Make sure the interface we want to use actually exists
                            if (typeInterface != null)
                            {
                                //Create a new available plugin since the type implements the IPlugin interface
                                Types.AvailablePlugin newPlugin = new Types.AvailablePlugin();

                                //Set the filename where we found it
                                newPlugin.AssemblyPath = FileName;

                                //Create a new instance and store the instance in the collection for later use
                                //We could change this later on to not load an instance.. we have 2 options
                                //1- Make one instance, and use it whenever we need it.. it's always there
                                //2- Don't make an instance, and instead make an instance whenever we use it, then close it
                                //For now we'll just make an instance of all the plugins
                                newPlugin.Instance = (IPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
                                //Set the Plugin's host to this class which inherited IPluginHost
                                newPlugin.Instance.Host = this;

                                //Call the initialization sub of the plugin
                                //newPlugin.Instance.Initialize(null,null);

                                //Add the new plugin to our collection here
                                colAvailablePlugins.Add(newPlugin);

                                //cleanup a bit
                                newPlugin = null;
                            }
                            typeInterface = null; //Mr. Clean
                        }
                    }
                }
                pluginAssembly = null; //more cleanup
            }
            catch (Exception ex)
            {
                Log2.Error("Error in Add Plugin!", ex);
            }
        }
Example #8
0
 /// <summary>
 /// Finds a plugin in the available Plugins
 /// </summary>
 /// <param name="pluginNameOrPath">The name or File path of the plugin to find</param>
 /// <returns>Available Plugin, or null if the plugin is not found</returns>
 public Types.AvailablePlugin Find(string pluginNameOrPath)
 {
     Types.AvailablePlugin toReturn = null;
     foreach (Types.AvailablePlugin pluginOn in this.List)
     {
         if ((pluginOn.Instance.Name.Equals(pluginNameOrPath)) || pluginOn.AssemblyPath.Equals(pluginNameOrPath))
         {
             toReturn = pluginOn;
             break;
         }
     }
     return(toReturn);
 }
Example #9
0
            /// <summary>
            /// Finds a plugin in the available Plugins
            /// </summary>
            /// <param name="pluginNameOrPath">The name or File path of the plugin to find</param>
            /// <returns>Available Plugin, or null if the plugin is not found</returns>
            public Types.AvailablePlugin Find(string pluginNameOrPath)
            {
                Types.AvailablePlugin toReturn = null;

                //Loop through all the plugins
                foreach (Types.AvailablePlugin pluginOn in List)
                {
                    //Find the one with the matching name or filename
                    if ((pluginOn.Instance.Name.Equals(pluginNameOrPath)) || pluginOn.AssemblyPath.Equals(pluginNameOrPath))
                    {
                        toReturn = pluginOn;
                        break;
                    }
                }
                return(toReturn);
            }
Example #10
0
        private void AddPlugin(string FileName)
        {
            //创建插件
            Assembly pluginAssembly = Assembly.LoadFrom(FileName);

            //获取方法类型
            foreach (Type pluginType in pluginAssembly.GetTypes())
            {
                if (pluginType.IsPublic)                 //必须是 public
                {
                    if (!pluginType.IsAbstract)          //不能为abstract types
                    {
                        Type typeInterface = pluginType.GetInterface("Svr.Plugin.Interface.IPlugin", true);

                        //确定必须实现PluginInterface.IPlugin方法
                        if (typeInterface != null)
                        {
                            //创建一个指定插件
                            Types.AvailablePlugin newPlugin = new Types.AvailablePlugin();

                            newPlugin.AssemblyPath = FileName;

                            newPlugin.Instance = (IPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
                            //设置插件的KEY sunlq
                            newPlugin.Instance.Key = System.IO.Path.GetFileNameWithoutExtension(FileName);
                            //调用初始化方法
                            newPlugin.Instance.Initialize();

                            //当前插件插入到插件队列
                            this.colAvailablePlugins.Add(newPlugin);

                            //cleanup a bit
                            newPlugin = null;
                        }

                        typeInterface = null;                         //Mr. Clean
                    }
                }
            }

            pluginAssembly = null;             //more cleanup
        }
Example #11
0
        private void AddPlugin(string FileName)
        {
            Assembly pluginAssembly = Assembly.LoadFrom(FileName);

            try
            {
                foreach (Type pluginType in pluginAssembly.GetTypes())
                {
                    if (pluginType.IsPublic)
                    {
                        if (!pluginType.IsAbstract)
                        {
                            //Gets a type object of the interface we need the plugins to match
                            Type typeInterface = pluginType.GetInterface("pluginfo.IPlugin", true);

                            //Make sure the interface we want to use actually exists
                            if (typeInterface != null)
                            {
                                //Create a new available plugin since the type implements the IPlugin interface
                                Types.AvailablePlugin newPlugin = new Types.AvailablePlugin();

                                //Set the filename where we found it
                                newPlugin.AssemblyPath = FileName;
                                newPlugin.Instance     = (IPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));

                                //Add the new plugin to our collection here
                                this.colAvailablePlugins.Add(newPlugin);
                                newPlugin = null;
                            }

                            typeInterface = null;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("There is an error in:\n" + FileName + "\n\nOriginal error:\n" + ex.Message);
            }

            pluginAssembly = null;
        }
Example #12
0
 /// <summary>
 /// Remove a Plugin to the collection of Available plugins
 /// </summary>
 /// <param name="pluginToRemove">The Plugin to Remove</param>
 public void Remove(Types.AvailablePlugin pluginToRemove)
 {
     List.Remove(pluginToRemove);
 }
Example #13
0
            //A Simple Home-brew class to hold some info about our Available Plugins

            /// <summary>
            /// Add a Plugin to the collection of Available plugins
            /// </summary>
            /// <param name="pluginToAdd">The Plugin to Add</param>
            public void Add(Types.AvailablePlugin pluginToAdd)
            {
                List.Add(pluginToAdd);
            }
Example #14
0
        private void AddPlugin(string FileName)
        {
            Assembly pluginAssembly = Assembly.LoadFrom(FileName);
            foreach (Type pluginType in pluginAssembly.GetTypes())
            {
                if (pluginType.IsPublic) //Only look at public types
                {
                    if (!pluginType.IsAbstract)  //Only look at non-abstract types
                    {
                        Type typeInterface = pluginType.GetInterface("PluginInterface.IPlugin", true);
                        if (typeInterface != null)
                        {
                            Types.AvailablePlugin newPlugin = new Types.AvailablePlugin();
                            newPlugin.AssemblyPath = FileName;
                            newPlugin.Instance = (IPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
                            newPlugin.Instance.Host = this;
                            newPlugin.Instance.Initialize();
                            this.colAvailablePlugins.Add(newPlugin);
                            newPlugin = null;
                        }
                        typeInterface = null;
                    }
                }
            }

            pluginAssembly = null;
        }
Example #15
0
		/**
		* Adds a plugin to the plugin collection
		*/
		private void AddPlugin(string fileName)
		{
			try 
			{
				Assembly pluginAssembly = Assembly.LoadFrom(fileName);
				foreach (Type pluginType in pluginAssembly.GetTypes())
				{
					if (pluginType.IsPublic)
					{
						if (!pluginType.IsAbstract)
						{
							Type typeInterface = pluginType.GetInterface("PluginCore.IPlugin", true);
							if (typeInterface != null)
							{
								Types.AvailablePlugin newPlugin = new Types.AvailablePlugin();
								newPlugin.AssemblyPath = fileName;
								newPlugin.Instance = (IPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
								newPlugin.Instance.Host = this;
								newPlugin.Instance.Initialize();
								this.colAvailablePlugins.Add(newPlugin);
								newPlugin = null;
							}
							typeInterface = null;
						}
					}
				}
				pluginAssembly = null;
			}
			catch (Exception ex)
			{
				ErrorHandler.AddToLog(ex);
			}
		}
Example #16
0
 private void AddPlugin(string FileName)
 {
     Assembly pluginAssembly = Assembly.LoadFrom(FileName);
     foreach (Type pluginType in pluginAssembly.GetTypes())
     {
         if (pluginType.IsPublic)
         {
             if (!pluginType.IsAbstract)
             {
                 if (pluginType.IsSubclassOf(typeof(IPlugin)))
                 {
                     Types.AvailablePlugin newPlugin = new Types.AvailablePlugin();
                     newPlugin.AssemblyPath = FileName;
                     newPlugin.Type = pluginAssembly.GetType(pluginType.ToString());
                     if (FiddlerControls.Options.PluginsToLoad.Contains(pluginType.ToString()))
                     {
                         newPlugin.CreateInstance();
                         newPlugin.Instance.Host = this;
                         newPlugin.Instance.Initialize();
                     }
                     this.colAvailablePlugins.Add(newPlugin);
                     newPlugin = null;
                 }
             }
         }
     }
     pluginAssembly = null;
 }
        private void AddPlugin(string FileName)
        {
            //Create a new assembly from the plugin file we're adding..
            Assembly pluginAssembly = Assembly.LoadFrom(FileName);

            //Next we'll loop through all the Types found in the assembly
            foreach (Type pluginType in pluginAssembly.GetTypes())
            {
                if (pluginType.IsPublic) //Only look at public types
                {
                    if (!pluginType.IsAbstract)  //Only look at non-abstract types
                    {
                        //Gets a type object of the interface we need the plugins to match
                        Type typeInterface = pluginType.GetInterface("PluginInterface.IFlamingPlugin", true);

                        //Make sure the interface we want to use actually exists
                        if (typeInterface != null)
                        {
                            //Create a new available plugin since the type implements the IPlugin interface
                            Types.AvailablePlugin newPlugin = new Types.AvailablePlugin();

                            //Set the filename where we found it
                            newPlugin.AssemblyPath = FileName;

                            //Create a new instance and store the instance in the collection for later use
                            //We could change this later on to not load an instance.. we have 2 options
                            //1- Make one instance, and use it whenever we need it.. it's always there
                            //2- Don't make an instance, and instead make an instance whenever we use it, then close it
                            //For now we'll just make an instance of all the plugins
                            newPlugin.Instance = (IFlamingPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));

                            //Set the Plugin's host to this class which inherited IPluginHost
                            newPlugin.Instance.Host = this;

                            //Call the initialization sub of the plugin
                            newPlugin.Instance.Initialize();

                            //Add the new plugin to our collection here
                            this.colAvailablePlugins.Add(newPlugin);

                            //cleanup a bit
                            newPlugin = null;
                        }

                        typeInterface = null; //Dispose It
                    }
                }
            }

            pluginAssembly = null; //more cleanup
        }
Example #18
0
        private void AddPlugin(string FileName)
        {
            //�������
            Assembly pluginAssembly = Assembly.LoadFrom(FileName);

            //��ȡ��������
            foreach (Type pluginType in pluginAssembly.GetTypes())
            {
                if (pluginType.IsPublic) //������ public
                {
                    if (!pluginType.IsAbstract)  //����Ϊabstract types
                    {
                        Type typeInterface = pluginType.GetInterface("Svr.Plugin.Interface.IPlugin", true);

                        //ȷ������ʵ��PluginInterface.IPlugin����
                        if (typeInterface != null)
                        {
                            //����һ��ָ�����
                            Types.AvailablePlugin newPlugin = new Types.AvailablePlugin();

                            newPlugin.AssemblyPath = FileName;

                            newPlugin.Instance = (IPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
                            //�����KEY sunlq
                            newPlugin.Instance.Key = System.IO.Path.GetFileNameWithoutExtension(FileName);
                            //���ó�ʼ������
                            newPlugin.Instance.Initialize();

                            //��ǰ������뵽�������
                            this.colAvailablePlugins.Add(newPlugin);

                            //cleanup a bit
                            newPlugin = null;
                        }

                        typeInterface = null; //Mr. Clean
                    }
                }
            }

            pluginAssembly = null; //more cleanup
        }