RichP's Blog

The .Net ramblings of Richard Penrose

Windsor IOC – Notes and Code Samples

without comments

I have been messing around with Windsor recently and I thought I would jot down some notes. I have also add some code samples to demonstrate various aspects of Windsor. See code samples at the bottom of the post.

Dependency Injection / IOC

Before going any further make sure you understand the concepts of IOC and Dependency injection. Mr Fowler does quite a good job of explaining things here:
Inversion of Control Containers and the Dependency Injection pattern.

Why use Dependency Injection / IOC

  • Flexibility
  • Ease of testing

What is an IOC container

A facility that helps to wire up classes which follow the IOC / dependency injection principle
I like to think of it as an object factory on steroids.

Container Patterns

There are two main container patterns in use today:

The Windsor Container

The Windsor container is on of several good IOC containers. Its been around for a while and it offers all of the main areas of functionality that you would expect from a container. For more info see: Inversion of Control Containers and the Dependency Injection pattern.

How to use Windsor

  • Design code using the Dependency Injection Pattern
  • Configure the Windsor Container
  • Use the container to resolve object instances.

Code Samples

Click here: IOC Code Samples to download four projects which demonstrate the following:

  • How to use Windsor
  • How to use Windsor including dependencies and overrides
  • How to configure Windsor using a config file
  • The default singleton instancing adopted by Windsor

I hope this is useful…..

Written by admin

March 31st, 2010 at 12:46 pm

Posted in Design Patterns