473,387 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Interfaces problem

pnp
Hi all,
I've created an app that loads some dlls dynamically from the
filesystem. All the dlls implement a certain interface so that they can
be easily manipulated from the main app. The dlls work as plugins for
the main app.
What I want to do is give some extra functionality to the dlls so that
each dll can have some extra functions inside it, that the other dlls
are not required to have (so I cannot add more functions to the main
interface that all the dlls implement). I would like all the changes to
be made to the plugin dlls and not the main app (so when a new plugin is
created I wouldn't like to change the main app as well).

How can I achieve this?

-pnp
Nov 16 '05 #1
3 1107
pnp wrote:
Hi all,
I've created an app that loads some dlls dynamically from the
filesystem. All the dlls implement a certain interface so that they can
be easily manipulated from the main app. The dlls work as plugins for
the main app.
What I want to do is give some extra functionality to the dlls so
that each dll can have some extra functions inside it, that the other
dlls are not required to have (so I cannot add more functions to the
main interface that all the dlls implement). I would like all the
changes to be made to the plugin dlls and not the main app (so when a
new plugin is created I wouldn't like to change the main app as well).

How can I achieve this?

-pnp

You can create the classes inheriting from the classes which implement
the common interfaces. I just don't see why there is any problem there.

Jianwei
Nov 16 '05 #2
pnp
When I load the dll, I use it's functionality by unwraping it and
casting it to the main interface. If I create a class that inherits from
a class that implements the interface how would I use it's functions?

John Sun wrote:
pnp wrote:
Hi all,
I've created an app that loads some dlls dynamically from the
filesystem. All the dlls implement a certain interface so that they
can be easily manipulated from the main app. The dlls work as plugins
for the main app.
What I want to do is give some extra functionality to the dlls so
that each dll can have some extra functions inside it, that the other
dlls are not required to have (so I cannot add more functions to the
main interface that all the dlls implement). I would like all the
changes to be made to the plugin dlls and not the main app (so when a
new plugin is created I wouldn't like to change the main app as well).

How can I achieve this?

-pnp


You can create the classes inheriting from the classes which implement
the common interfaces. I just don't see why there is any problem there.

Jianwei

Nov 16 '05 #3
I see two possible solutions, depending upon how the extra functions in
the various DLLs are related, and whether they logically fall into
groups that must either be completely implemented or not implemented at
all.

If you are going to have groups of extra functions, you could create
other interfaces that a given class may implement or not. Then, in the
main class, you could say

IOptionalInterface1 oi1 = loadedClass as IOptionalInterface1;
if (oi1 != null)
{
... call methods in optional interface ...
}

On the other hand, if your optional methods / properties are not
related in this way, then you may have to resort to using Reflection
and testing for particular method names. You can then invoke the
methods using Reflection as well.

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Franco Gustavo | last post by:
Hi, Please help me to understand this, because I don't see what I'm missing. I was reading a lot of examples on Internet that explain that C# doesn't implement multiple inheritance it...
3
by: Darren | last post by:
Do event members belong in interfaces? I have used events in interfaces to report state changes and they work well. However; I really never see event members in any of the framework interfaces. ...
17
by: Picho | last post by:
Hi all, I popped up this question a while ago, and I thought it was worth checking again now... (maybe something has changed or something will change). I read this book about component...
30
by: Frank Rizzo | last post by:
We are having one of those religious debates at work: Interfaces vs Classes. My take is that Classes give you more flexibility. You can enforce a contract on the descendant classes by marking...
18
by: _dee | last post by:
Question about best use of interfaces: Say there's a 'Master' class that needs to implement a few interfaces: class Master : I1, I2, I3 { } The actual code already exists in smaller...
22
by: RSH | last post by:
Hi, I have been reading on interfaces working on samples I've run across on the web. For the life of me I cannot seem to grasp them. It appears to me that interfaces are simply blueprints to...
23
by: A.Gallus | last post by:
If I declare a function pure virtual: class A { virtual void myfunc() = 0; } and I derive a class from A: class B : public A
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.