I'm developing an application that makes heavy use of plugins. The app is in C# and I'm thinking about building the configuration GUI in WPF. I got the plugin architecture down in terms of how to manage the actual plugins themselves. However, each plugin has its own configuration, and that's where I'm looking for help.
The plugin architecture is simple — there's an interface that plugins implement and I just load all the plugins inside a directory. However, where do the plugins get their configuration from? I'd like to have some generic way of handling this, so that each plugin isn't responsible for reading its own configuration file. Also, I'd like the GUI to expand with each plugin — that is, each plugin installed should add a tab to the GUI with the specific configuration options for that plugin. Then upon save, the configuration file(s) would be saved.
What's my best way of going about this?
Best Answer
Define an interface for configurable plugins:
The just invoke the IConfigurable interface for configurable plugins.
If you want you can make the interface work the other way, making the main application provide a container (a frame or a dock for example) to the plugin for it too feel, but I would recommend the other way around.
Finally you can do it the hard way, by defining exactly what the plugin can offer as configuration option.
of course this option is the more restrictive and more secure one, since you can limit perfectly how the plugin is able to interact with the configuration window.