|
-
Apr 29th, 2009, 02:12 AM
#10
Re: Automating Host through an AddIn
If you want the plug-in to be able to call a method of "the application" directly then the plug-in has to be aware of the type that represents the application. That would mean defining another interface to represent the application and then your plug-in interface would have to have a property of that type. The host app would then pass an object of that type to the plug-in so the plug-in can call its methods.
If you go the option I'm recommending then you don't need the extra interface and your plug-in interface simply adds some events and your plug-in raises those events when it needs to notify the application that something has or should happen. The application will then act accordingly. For instance, instead of the app exposing a Beep method that the plug-in would call, the plug-in would raise a Beep event,, which the app would handle and then make a Beep sound.
It's exactly the same as having a Button on your form to perform some action. When the user clicks the Button it doesn't call a method of your form does it? No, it doesn't. It simply raises its Click event. It's up to the form to handle that event and then act accordingly.
You should also note that, if you need to pass data from the plug-in to the app, you can do so through the event's arguments.
I would suggest that you do a bit of reading on defining and raising events.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|