I have a strategic question for the C # project. I want to implement a plug-in concept and now want to fight the best of plugins to manipulate the main project's data.
Firstly I created a "Master" plugin project which defines the interface plugins and an attribute for identifying a class as a pluginclass when I load it into my main project. [AttributeUsage (AttributeTargets.Class, AllowMultiple = false, Traditionally Received = true)] Public Seal Class GraphViewerPlugInAttribute: Attribution {} Public Interface IGraphViewerPlugIn {Panel GetRightSidePanel (); String name (); }
Then this project has been referred to in the main project and plug-ins classes apply the pluginclass interface ...
[GraphViewerPlugIn] public Square myTestPlugIn: IGraphViewerPlugIn {Public Panel GetRightSidePanel () {panel myPanel = new panel (); MyPanel.BackColor = System.Drawing.Color.Red; MyPanel return; } Public string name () {return "TestPlugIn"; }} ... and the main project loads all plugins that are stored in a fixed directory.
It still works quite well, I have a panel with a special plugin, but now I want to manipulate the main project's data from within the plugin. What would be the best way to do this? I have some type of data-Container-class that is defined in the brain in the "Master Plugin Project". The plugin puts data in that container and the main project will be identified by the event that the data has changed and can now see which data has changed and then the changes are applied. Is this the right direction, what do I have to do and what technique (i.e. events, static class ...) will I use to apply it?
There is a way to add a configuration button that activates a method on the design interface for configuration is.
This method can use any code that it wants to configure, plug it in, including creating your calls for Windows Forms
If you use windows or Wifx Is not using, and there is no custom UI, this is the ideal way because it removes all the logic related to the plugin from the application, only for notifying that a configuration window was requested.
Public Interface IGraphViewerPlugIn {Panel GetRightSidePanel (); String name (); Zero ShowConfigurationDialog (); } Of course, you can then implement ShowConfigurationDialog in this way:
Public Zero ShowConfigurationDialog () {form form = new MyConfigurationDialog (); Form.ShowDialog (); } Where to configure the plugin MyConfigurationDialog has created your Designer form.
Comments
Post a Comment