473,811 Members | 2,971 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Providing a programming interface to a plugin

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
1 1955
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.co m
"Olie" <ow****@gmail.c omwrote in message
news:11******** **************@ m36g2000hse.goo glegroups.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
282
by: Donald Smith | last post by:
Hello, Does anyone know how to code plugins, or code run off your own program that affects another program? Example: File1.exe sends the string "Test" to File2.exe (A Completely different program) and "Test" Appears in a textbox on File2.exe. Its kind of hard to explain, but I hope you know what I mean. I'm not asking for code on how to do that, I'm asking for the general idea on how to do it,
4
5699
by: Shane | last post by:
I am having a problem where I create an instance of a class from an assembly and I try to cast it to an interface that it inherits from and it says that the cast is invalid. Here is the code: Interface.IParser objPlugin; Interface.PluginServices parserService = new Interface.PluginServices(); objPlugin = (Interface.IParser)parserService.CreateInstance(_parser); return objPlugin.ParserName;
4
1320
by: SStory | last post by:
I have an app that I am about ready to beta and then sell--hopefully. It is small scale but nevertheless a commercial app. Anyhow, I have obfuscated my code with the free version. My real question is, how can I provide updates to those who've purchased the product? Would be nice to use like the install shield or wise--free patch utility of old. I'm not sure that would be possible or not. Especially with obfuscated code. Any real...
12
1699
by: you | last post by:
I may be just stupid, but I don't understand the point of using an Interface. I am going through a couple of books at the moment trying to teach myself a little vb.net. Just for the heck of it, ya know. Kinda interesting stuff. Anyhoo; Both of these talk about what an interface is, give an example, and then happily go on their merry way leaving me to guess as to WHY you would create and use one?
1
1085
by: theinvisibleGhost | last post by:
Is there an underlying interface anywhere that .NET form controls use to include the Enter, Leave, GotFocus, and LostFocus events? I have a problem where I've got a usercontrol which is being used in a Media Player Plugin. The plugin offers C# Scripting capabilities through an Open Source Scripting engine. I want to detect if scripts have been changed by another program.
3
2222
by: auad | last post by:
hi, I'm having a problem with plugins....as follows: I have 3 projects: 2 class libraries and 1 Windows App (Project 1: ClassLibrary) I have a plugin interface: -------------------------------------------------------------------- namespace API {
1
1256
by: Manuela Abele | last post by:
Hello everybody, I have a problem with interface and I need urgent your help. public interface IKoerper { // Properties int laenge { get; } int breite { get; } int hoehe { get; }
0
1383
by: gerdhub | last post by:
I develop an application that uses a plugin interface, that the hosting application as well as the plugins implement. Each plugin is loaded via: newPlugin.Instance = (IPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); All Plugins are inside a sub directory called "plugins" of the main application. Now I developed one plugin that should implement a network interface, using external dll's from a framework i...
7
10602
by: WTH | last post by:
I am now aware (I am primarily a C++ developer) that in C# if you reference the same interface from the same file in two different projects the types are actually incompatible. I found this out because I have written a generic plugin system for my current and future C# needs. I defined a base plugin system interface named IPlugin (original, I know...) which contains some basic plugin infomration all plugins of this system must expose...
0
9730
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10136
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9208
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7671
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6893
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4341
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3868
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3020
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.