Register a factory as decorator

Sep 25, 2014 at 8:29 AM
Hi Steven,

finally, back to using Simple Injector :)
And immediately, I have a question:

I am using LinFu to automatically create logging decorators for my interfaces.

Sample code - without DI - looks like this:
    public static IInterface Create()
        var impl = new ActualImplementation(args);
        return _proxyFactory.CreateProxy<Interface>(new LoggingInterceptor(impl));
I completely want to get rid of this Create method, but I don't know how to register this CreateProxy method as a decorator.

Any idea?

Sep 25, 2014 at 8:51 AM
Hi Daniel,

I'm not completely sure what you're trying to do but it seems you are using interception instead of decoration, which probably means you are trying to apply the interceptor to a wide range of interfaces. Using the ExpressionBuilt event, you can change a registration to apply an interceptor to it. Here's an example that uses Castle Dynamic Proxy for this, and it will probably be quite easy to rewrite it to use LinFu.
Marked as answer by dot_NET_Junkie on 9/28/2014 at 4:01 AM
Sep 25, 2014 at 8:54 AM
Thanks, that looks just like what I need!