468,321 Members | 1,817 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,321 developers. It's quick & easy.

Plugins: flexible & safe use of different assembly versions withdifferent features

Hello.

Are there any resources out there (because I couldn´t find any)
concerning the usage of assemblies with different features in each version?

In other words:
I´ve got one assembly A that is using assembly B - B exists in different
versions. Now I want to make it possible for A to ask B what features it
supports or what data it can give to A.

Something like:

if (B.supports(detailedData))
useDetailedData();
else if (B.supports(lessDetailedData))
useLessDetailedData();
else
useData();

An older version of A may ask only the following:
if (B.supports(lessDetailedData))
useLessDetailedData();
else
useData();

I´ve tried something like this but it didn´t work for me!

Puh - hope I could make myself clear.
Thanks for any information!

Greetings,
Tim.
Mar 22 '06 #1
1 1196
I'm not sure how you have created your assemblies, but generally
speaking, you would define an interface that B would implement. A
would be programmed against this interface. As long as the assembly
(B) has implemented the interface properly, it doesn't matter to A how
it is implemented, it should just work. This way, A doesn't have to
know what capabilities B has and B doesn't have to know what A
supplies. A just calls the interface, and B just implements it. I
suppose you could have A pass in its version number so that B can react
accordingly.

public interface IMyInterface
{
//interface definition here
public void InterfaceMethod();
}

public class PlugIn : IMyInterface
{
//PlugIn (B) implements the interface
public void InterfaceMethod()
{
//method implementation
}
}

public class Host
{
//Host class (A) uses the interface

IMyInterface var;

public Host()
{
var = getInterfaceInstance();
}

private IMyInterface getInterfaceInstance()
{
//code to instantiate an object that implements the interface
}

private void foo()
{
var.InterfaceMethod();
}
}

Hope this helps.

Mar 22 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Arnaud Debaene | last post: by
5 posts views Thread by Florian Proch | last post: by
6 posts views Thread by Pete Davis | last post: by
4 posts views Thread by Antnio Pinho | last post: by
reply views Thread by Greg Conely via .NET 247 | last post: by
reply views Thread by Jason Madison | last post: by
1 post views Thread by howard w | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.