Created
July 4, 2012 14:03
-
-
Save kstenson/3047511 to your computer and use it in GitHub Desktop.
Autofac intercepter setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//this class registers the two interceptors in the container with a name for each | |
public class InterceptorsModule: Module | |
{ | |
protected override void Load(ContainerBuilder builder) | |
{ | |
builder.Register(x => new LoggingInterceptor()).Named<IInterceptor>("Logger"); | |
builder.Register(x => new TimingInterceptor()).Named<IInterceptor>("Timing"); | |
} | |
} | |
//Then in your application you add the interceptors to you objects using the methods below. You can use //assembly scanning to do this for every object instead of individual ones | |
builder.Register(x => new EDIAdapter()).As<IAdapter<Bill>>() | |
.EnableInterfaceInterceptors() | |
.InterceptedBy("Logger") | |
.InterceptedBy("Timing"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment