By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,610 Members | 1,957 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,610 IT Pros & Developers. It's quick & easy.

Providing a programming interface to a plugin

P: n/a
I was quite surprised to find virtually nothing about this but I may
have been searching for the wrong thing.

I want to know the best way to provide a programming interface to a
plugin. I already have a plugin architecture that allows the
application to call code in a plugin but I want the plugin to also be
able to call code in the application.

I can think of many ways to do this but I am not sure the best way:

Option 1:

The plugin inherits a class that has one function called
GetInterface(), This returns a reference that can be cast to different
Interface types.

Option 2:

The plugin is passed a reference to the application interface which
contains all the callable functions.

Option 3:

The plugin can create an object that has all the API functions in it
e.g. Stop, Pause and Play. (The problem with this is how do you
actually connect those functions back to the main application.) I
suppose this would be similar to the office api or activeX interfaces.

I want to choose the best way that will also allow me to update the
API without breaking any existing plugins.

Any advice is welcomed!

May 22 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Olie,

I would recommend defining two more interfaces. The first is an
interface that your application object implements. The second is one which
your plug in implements. The interface that the plugin implements (in
addition to the one it already implements) has one method which allows you
to assign the interface for the application to it. It's a way of the plugin
to say "I want a reference to the host".

You have a separate interface for your host (which is contained outside
of the host assembly) so that you don't have to worry about versioning as
much.

Then, you can do your plugin processing normally.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Olie" <ow****@gmail.comwrote in message
news:11**********************@m36g2000hse.googlegr oups.com...
>I was quite surprised to find virtually nothing about this but I may
have been searching for the wrong thing.

I want to know the best way to provide a programming interface to a
plugin. I already have a plugin architecture that allows the
application to call code in a plugin but I want the plugin to also be
able to call code in the application.

I can think of many ways to do this but I am not sure the best way:

Option 1:

The plugin inherits a class that has one function called
GetInterface(), This returns a reference that can be cast to different
Interface types.

Option 2:

The plugin is passed a reference to the application interface which
contains all the callable functions.

Option 3:

The plugin can create an object that has all the API functions in it
e.g. Stop, Pause and Play. (The problem with this is how do you
actually connect those functions back to the main application.) I
suppose this would be similar to the office api or activeX interfaces.

I want to choose the best way that will also allow me to update the
API without breaking any existing plugins.

Any advice is welcomed!

May 22 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.