I have 2 assemblies:
Assembly 1:
interface IWeapon {
int Might { get; }
}
[Export("sword")]
public class Sword : IWeapon {
public int Might {
get { return 10; }
}
}
Assembly 2:
interface IWeapon {
int Might { get; }
}
var catalog = new AssemblyCatalog(typeof(Ninja.Sword).Assembly);
var container = new CompositionContainer(catalog);
// not allowed to use the IWeapon def in assembly 2
var sword = container.GetExportedValue<IWeapon>("sword");
I know how to get this to work. I can either ask the MEF (Managed Extensibility Framework) for the object, or get it to export the correct IWeapon instead of just the object by name.
Can MEF do the "duck" typing for me and return a proxy object if all the interface points are implemented?