LightInject icon indicating copy to clipboard operation
LightInject copied to clipboard

Alternative to MEF plugins

Open WonkySoft opened this issue 4 years ago • 3 comments

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.

WonkySoft avatar May 22 '20 19:05 WonkySoft

Hi @WonkySoft Could you come with a simple example/repro of what you are trying to do? 😊

seesharper avatar May 25 '20 09:05 seesharper

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>>.

WonkySoft avatar May 26 '20 02:05 WonkySoft

Was the information I added sufficient?

WonkySoft avatar Jun 12 '20 00:06 WonkySoft