Autofac.Extras.DynamicProxy
Autofac.Extras.DynamicProxy copied to clipboard
Conditional registration for interceptors
Problem Statement
Based on autofac/Autofac#1211 - it may be interesting to have the ability to conditionally enable interception based on a lambda expression. This does somewhat overlap with #29.
Desired Solution
I imagine the usage would be like:
builder
.RegisterAssemblyTypes(typeof(Program).Assembly)
.AsClosedTypesOf(typeof(ICommandHandler<,>))
.EnableInterfaceInterceptors(t => t.HasSpecificAttributeICareAbout())
.InterceptedBy(typeof(LoggingInterceptor));
That is, you could act on the registration based on the type being registered. (Honestly, this part needs some work. I haven't thought it all the way through. It may be there's a better way to go here.)