I’m designing an application that supports plugin development. Its more of a learning exercise.
All of the assemblies (plugins) being loaded into my app contain a showPrefs() method. As I load each assembly, I want to assign a button to each one so that when I click on the button, it triggers the showPrefs() method of the assembly that the button is assigned to.
How do I do this? A quick and dirty solution would be to change the showPrefs() method signature to be showPrefs(object sender, EventArgs e). This way I can assign it to the button but I think this is a cheap workaround around.
Any ideas?
The click event handler only accepts delegates that have the method signature of (object o, EventArgs e) so I don’t know how I would assign the showPrefs() method to the click event.
Thats the bit I’m having trouble with.
If you look at Will’s pseudocode, he assigns a lambda expression to the Click handler, like such:
That’s an anynomous method right there, accepting an object and EventArgs. It then calls your showPrefs function on the interface. It’s roughly equal to the following:
Which might be useful if you’re using c# 2.0.