Created
June 24, 2014 22:44
-
-
Save lukeschafer/1f3e30b3537994a073e8 to your computer and use it in GitHub Desktop.
Nimbus Autofac Interceptor Workaround
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
public static class InterceptorExtensions | |
{ | |
public static ContainerBuilder WithInbound<TInterceptor>(this ContainerBuilder builder, Func<IComponentContext, TInterceptor> factory = null) | |
where TInterceptor : IInboundInterceptor | |
{ | |
if (factory != null) | |
builder.Register(factory).AsSelf().As<IInboundInterceptor>().Named<TInterceptor>(typeof (TInterceptor).FullName); | |
else | |
builder.RegisterType<TInterceptor>().AsSelf().As<IInboundInterceptor>().Named<TInterceptor>(typeof(TInterceptor).FullName); | |
return builder; | |
} | |
public static ContainerBuilder WithOutbound<TInterceptor>(this ContainerBuilder builder, Func<IComponentContext, TInterceptor> factory = null) | |
where TInterceptor : IOutboundInterceptor | |
{ | |
if (factory != null) | |
builder.Register(factory).AsSelf().As<IOutboundInterceptor>().Named<TInterceptor>(typeof(TInterceptor).FullName); | |
else | |
builder.RegisterType<TInterceptor>().AsSelf().As<IOutboundInterceptor>().Named<TInterceptor>(typeof(TInterceptor).FullName); | |
return builder; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment