Re: Plugins: flexible & safe use of different assembly versions with different features



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.

.



Relevant Pages

  • Re: List<> classes and inheritance (C#)
    ... I think the answer to your question is the use of an interface that all ... public class MyClass1: IMyInterface ... There may be no need at all to override the Add method at this point because ...
    (microsoft.public.dotnet.csharp.general)
  • Problem with casting same COMImport interface from 2 different assemblies
    ... A class in assembly A implements a COM interface as follows: ... internal interface IMyInterface ... class MyClass: IMyInterface ...
    (microsoft.public.dotnet.framework.interop)
  • Re: cyclic dependency
    ... but I see cyclical references between ... assemblies as a sign of bad design. ... public class ProjectA: System.Windows.Forms.Form ... > to implement the Separated Interface Pattern. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Why not multiple inheritance in C# and java
    ... "mirror" of the innards of the business objects. ... Windows control type, and that offends me. ... > You can mimic MI by delegating your interface to a class implementing the ... > IMyInterface GetMyInterface() ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How to hide an interface in C#
    ... public class A, IMyInterface ... void IMyInterface.MafonctionTresPrivee ... reference to the interface). ... > internal Interface ImyInterface ...
    (microsoft.public.dotnet.languages.csharp)