This post is, I believe, long overdue. In Part 1 of this series, I said I would demonstrate how to perform auto registration so here it is. Consider the following code
which as you can see in the registration phase is registering two different implementations “HttpFileDownloader”, “AnotherHttpFileDownloader” for the same interface “IHtmlTitleRetriever”. This is a very contrived example and there would be no reason to have two different implementations. However, it illustrates how we can perform auto-registration in cases we have several implementations of the same interface. So, here is the code:
So in effect, Castle Windsor will also automatically register “AnotherHttpFileDownloader” as long as it’s in the same assembly as “HttpFileDownloader”.
Instead of “Types”, you might be using “AllTypes” but the latter is deprecated. The version of Castle Windsor I am using is 3.2.0.
There is nothing to it really.
I will not be writing any more blog posts about the basics of Castle Windsor because it is covered sufficiently in other resources e.g. Dependency Injection in .NET.