Skip to content

Instantly share code, notes, and snippets.

@kstenson
Created July 4, 2012 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kstenson/3047511 to your computer and use it in GitHub Desktop.
Save kstenson/3047511 to your computer and use it in GitHub Desktop.
Autofac intercepter setup
//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