Skip to content

Instantly share code, notes, and snippets.

@jpolvora
Last active December 11, 2015 16:08
Show Gist options
  • Save jpolvora/4625678 to your computer and use it in GitHub Desktop.
Save jpolvora/4625678 to your computer and use it in GitHub Desktop.
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();
}
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();
}
}
@SHannuschke
Copy link

Thanks a bunch. Saved me hours from digging myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment