Ayende @ Wiki

This very brief and simple tutorial assumes the reader is already familiar with the Windsor Inversion of Control container and will skip the traditional step of introducing a fictitious and embarrassingly simple domain model and service layer.

First, add references to the following libraries to your application (this example is based off a standard WebForms application).

  • Boo.Lang
  • Boo.Lang.Compiler
  • Boo.Lang.Parser
  • Castle.Core
  • Castle.Windsor
  • log4net
  • Rhino.Commons

and a reference to the library containing your services (in this case I am using BinsorDemo.Services).

These references can be found by by following the svn link found here and building the projects locally.

With that done, add a file called "windsor.boo" to your application, and add something similar to the following

import BinsorDemo.Services

creditLimitAmount as decimal = 500.0

component 'credit_service', ICreditService, CreditService: creditLimit=creditLimitAmount

interestRate as decimal = .0575

component 'interest_service', IInterestCalculator, InterestCalculator: baseRate = interestRate anotherParameter = "doesnt.need.to.be.a.variable"


Keep in mind that Binsor is a DSL based off of the Boo language, what was a config file in the XML world is now compiled code.

Then in your global.asax file, add something like this



public class Global : System.Web.HttpApplication { private static IWindsorContainer container;

public static IWindsorContainer Container { get { return container; } }

protected void Application_Start(object sender, EventArgs e) { XmlConfigurator.Configure(); string binsorConfigFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "windsor.boo"); container = new WindsorContainer(); BooReader.Read(container, binsorConfigFilePath); } }



In a nutshell, that's it. A quick test confirms that it works:

            Response.Write(Global.Container.Resolve().GetCreditFor(account));
            Response.Write(Global.Container.Resolve().CalculateInterestOn(account));

ScrewTurn Wiki version 2.0 Beta. Some of the icons created by FamFamFam.