Last active
December 11, 2015 16:08
-
-
Save jpolvora/4625678 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 App() { | |
InitializeComponent(); | |
/* passing a pre-configured (intercepted) windsor container to the IoC wrapper: */ | |
var windsor = new WindsorContainer(); | |
windsor.Register(Component.For<ContainerInterceptor>().LifeStyle.Transient); | |
windsor.Register(Component.For<IContainer>() | |
.UsingFactoryMethod<IContainer>(() => { | |
return new Container(windsor); | |
}) | |
.Interceptors<ContainerInterceptor>()); | |
var container = windsor.Resolve<IContainer>(); | |
new ClientConfiguration(typeof(HelloRequest).Assembly, container).Initialize(); | |
} |
This file contains hidden or 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 class ContainerInterceptor : IInterceptor { | |
//avoiding the invocation of the method "Release" | |
public void Intercept(IInvocation invocation) { | |
if (typeof(IContainer).IsAssignableFrom(invocation.TargetType)) { | |
if (invocation.Method.Name == "Release") { | |
return; | |
} | |
} | |
invocation.Proceed(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks a bunch. Saved me hours from digging myself.