In Castle Windsor 3, override an existing component registration in a unit test

There are two things that you have to do to create an overriding instance: Assign it a unique name Call the IsDefault method So to get the example to work: this.WindsorContainer.Register( Component.For<IMediaPlayerProxyFactory>() .Instance(mockMediaPlayerProxyFactory) .IsDefault() .Named(“OverridingFactory”) ); Because I plan to use this overriding patten in many tests, I’ve created my own extension method: public static … Read more

Castle Windsor are there any downsides?

To answer your questions: That is using reflection and each time that an object is called from the container, reflection must used so performance will be terrible. (Is this the case? does it use reflection on every call?) No, it does not. Most of the time it uses little reflection when you register the component. … Read more

Proper Hub dependency lifetime management for SignalR and Castle Windsor

I’ve had a bit similar problem but with Unity instead of Castle Windsor. My requirements: I wanted to avoid singleton registrations on the container. All objects are resolved in Hub and should be disposed on Hub destruction. Registrations reused across Web Api and SignalR. Object lifetime is managed by HierarchicalLifetimeManager – child containers resolve and … Read more

Which Dependency Injection Tool Should I Use? [closed]

Having recently spiked the use of 6 of these (Windsor, Unity, Spring.Net, Autofac, Ninject, StructureMap) I can offer a quick summary of each, our selection criteria and our final choice. Note: we did not look at PicoContainer.Net as one of our team considered the .Net port to be quite poor from the Java version. We … Read more

Design – Where should objects be registered when using Windsor [closed]

In general, all components in an application should be composed as late as possible, because that ensures maximum modularity, and that modules are as loosely coupled as possible. In practice, this means that you should configure the container at the root of your application. In a desktop app, that would be in the Main method … Read more

Comparing Castle Windsor, Unity and StructureMap

See here and here for a pretty thorough technical comparison of several IoC containers, although somewhat outdated by now (they’re from before Windsor 2.0) However, I don’t think there are really any vital features that Windsor offers and other containers don’t. Windsor, StructureMap, Spring.NET have all been around for several years and have been used … Read more