Mastodon

Castle Windsor has a great add on called the WCF Integration Facility which allows you to get all of the benefits of DI/IoC when working with WCF services.

The only downside of using it is the verbosity of the component registration. Thankfully we are able to use extension methods to help us here and hide away all of the verbose registration code behind a simple, chainable method call.

Register a WCF Service

Using an extension method, you can register a WCF service very simply and easily.

var netTcpBinding = new NetTcpBinding();
container.RegisterWcfService<IMyService, MyConcreteService>(netTcpBinding);

Register a WCF Client

WCF client registration also becomes very simple as well.

var httpBinding = new HttpBinding();
container.RegisterWcfClient<IMyService>(httpBinding, "http://your-url/service.svc");

The extension methods

These extension methods also return the IWindsorContainer intance allowing multiple registrations to be chained in a fluent manner.