LightInject
LightInject copied to clipboard
Alternative to MEF plugins
I have reflection code that lets me scan/load any assembly that has methods that meet a given signature and create proxies to those methods. It doesn't rely on any defined interface or attributes on the methods. I'm pretty sure I can achieve the same thing with MEF 1.0 and attributes, but ConventionBuilder in MEF 2.0 isn't documented well enough to determine if I can achieve the same thing without attributes.
So my question is, can this be (easily) achieved with LightInject? If so, can someone provide a simple example.
Hi @WonkySoft Could you come with a simple example/repro of what you are trying to do? 😊
Say each one of these is defined in a separate assembly:
public static class StaticThing
{
public static Task<bool> MyStaticMethod() =>
Task.FromResult(true);
}
public class InstanceThing
{
public Task<bool> MyInstanceMethod() =>
Task.FromResult(true);
}
public class InstanceWithStaticThing
{
public static Task<bool> MyStaticMethod() =>
Task.FromResult(true);
}
I want to be able to discover and proxy said methods from their assemblies in a given path based on method signature match, which in this case is something like Func<Task<bool>>
.
Was the information I added sufficient?