Contents tagged with ioc

  • Getting Started with Castle Windsor

    My preferred IoC container is StructureMap, but I’m going to be working with a client who uses Castle Windsor as their standard container, so I decided to learn a bit about it this week.  I created a simple console application and included some interfaces and implementations to see how things work.  Registering individual interfaces and wiring them up to their implementations is pretty straightforward: Getting resolved types out of the container is as well.  In this case, Greeter requires an IGreeting and an IWriter in its constructor: While you’re learning how to work with the container, it can be useful to see a list of everything that is currently registered.  I … more

  • A Gentle Introduction to StructureMap

    I found myself explaining inversion of control containers and their benefits to someone today, and so I created a very simple console application that makes use of StructureMap (my favorite such container).  You can view the whole file in this Gist.  Here I’ll just briefly explain what’s going on. The main benefit of a tool like StructureMap is to decouple your classes from their collaborators.  Rather than classes knowing exactly which implementations they’re working with, they publish their needs for collaborators in their constructors, providing explicit dependencies (see my other posts on dependencies).  The IoC container then is used to provide these classes with the … more