Windsor Extension
The Windsor extension will help you intialize your Windsor container by scanning for classes that implement WindsorRegistration and executing it's register method.
Installation
You can install the Windsor extension via
nuget over
here. Alternatively you can download the extension
here.
Creating Registrations
To initialize your container you must declare classes that implements IWindsorRegistration and implement the Register method. For example:
public class RegisterMyTypes: IWindsorRegistration
{
public void Register(IWindsorContainer container)
{
container.Register(Component.For<IMyType>().ImplementedBy<MyType>());
}
}
Native Registrations (new in 2.0.3.0)
Bootstrapper now supports the use of native registrations. Native registrations can be used by themselevs or in conjunction with Bootstrapper generic and specific registration. For Windsor, just declare a class implements IWindsorInstaller and Bootstrapper will use it to initialize the container.
public class TestWindsorInstaller: IWindsorInstaller
{
public void Install(IWindsorContainer container, IConfigurationStore store)
{
container.Register(Component.For<ITestInterface>().ImplementedBy<TestImplementation>());
}
}
Using the extension
To use the extension simply write this code:
Bootstrapper.With.Windsor().Start();
AutoRegistration
You can use the AutoRegistration option to indicate that you want to automatically register al types that implement an interface of the same name. For example, if you have an interface called IMyType and a type called MyType that implements IMyType then the Autoregistration option will Bind IMyType to MyType. To use the AutoRegistration option simply write this code:
Bootstrapper.With.Windsor().UsingAutoRegistration().Start();
Accessing the initialized Container
After Bootstrapper has been invoked and the container has been initialized it can be accessed with the Container property of Boostrapper. For example:
var container = (IWindsorContainer)Bootstrapper.Container;
Generic Registration
You can use
Generic Registration with the Ninject extension. For details go to the
Generic Registration page.