Overview
Here is a general look at the fluent registration in action. This is a simple registration of a component by a single interface.
IContainerManager containerManager = new ContainerManager(); // this will often be elsewhere var registration = containerManager.Adapter.CreateComponentRegistration<ComponentRegistration>() .Register<ISuperDependantClass>() .As<DependantClass>(); adapter.Register(registration);
Registering a component as multiple types
The fluent registration api allows the easy registration of components against multiple interfaces.
var registration = containerManager.Adapter.CreateComponentRegistration<ComponentRegistration>() .Register<IDependantClass, ISuperDependantClass>() .As<DependantClass>();
Named
Named registrations can be achieved simply by using the ‘Named’ method. This accepts the string of the registration name.
var registration = containerManager.Adapter.CreateComponentRegistration<ComponentRegistration>() .Register<ISuperDependantClass>() .As<DependantClass>() .Named("name");
Instance Registrations
Instance Registrations can be achieved simply by using the Instance() method. This accepts the instance of the object that you wish to return.
IContainerAdapter adapter = adapterFunc(); var returnClass = new DependantClass(); var registration = adapter.CreateComponentRegistration<ComponentRegistration>() .Register<ISuperDependantClass>() .Instance(returnClass); adapter.Register(registration);