Plugin design
I've managed to load .dll's at runtime through reflection and assembly. However, I would like the different plugins to be able to alter the main graphical user interface at runtime (Add nodes to treeview\listview etc).
At the moment my prototype is using the current interface for the plugins.
public interface IPlugin
{
string PluginName { get; }
string DisplayName { get; }
bool Enabled {get; }
bool Init( get; )
}
Would passing one or more delegates to the plugins be a good solution to enable the plugin to access for instance the listview object? Or could I pass a reference to one or more graphical objects? Any input on the matter would be much appreciated.
[741 byte] By [
laasunde] at [2007-11-20 1:38:45]

# 1 Re: Plugin design
personally, I wouldnt allow access to an object from the plugin. even if I was the only one who'd be writing the plugins. it keeps you from being tied to one way of doing things. creating a mechinism for giving the plugins the data needed from the listview, and allowing them to update info on the listview would be a better solution. this way if you ever wanted to change your core app, then you dont have a lot of breaking plugins.
# 2 Re: Plugin design
Thanks for your reply.
Tried searching a bit on the subject but not found any good articles yet.
One possible solution could be something like this but it might make the plugin to tighly coupled with the framework.
public interface IPlugin
{
bool Init(IHost Host);
...
}
public interface IHost
{
void AddListview(string str);
void AddTreeview(string str);
event ListItemSelected LIS;
event TreeItemSelected TIS;
...
}
Do you have a brief example or any good article(s) on your suggested design.