Re: Plugins: flexible & safe use of different assembly versions with different features
- From: "Chris Dunaway" <dunawayc@xxxxxxxxx>
- Date: 22 Mar 2006 07:19:46 -0800
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.
.
- References:
- Prev by Date: Re: Threading changes in .NET 2
- Next by Date: Passing Data From Cust Control To main Form [C# Win]
- Previous by thread: Plugins: flexible & safe use of different assembly versions with different features
- Next by thread: create xml element
- Index(es):
Relevant Pages
|