This project is read-only.

Generic Registration

Generic registration lets you write your container initialization code using a container-agnostic API. To use the generic registration all you have to do is write classes that implement BootstrapperRegistration and implement the Register method. Regardless of the Container Extension that you decide to use, classes that implement the IBootstrapperRegistration will execute and your container will be initialized correctly.
The use of Generic registration could be useful if you need to change your container, since all your container initialization code will not need to change. However, we don't recommend the use of Generic Registration if your container initialization needs are more advanced.

Creating Registrations

To initialize your container you must declare classes that implements IBootstrapperRegistration and implement the Register method. For example:
public class RegisterMyTypes: IBootstrapperRegistration
    public void Register(IBootstrapperContainerExtension containerExtension)
The following methods are available for registration
void Register<TTarget,TImplementation>() where TTarget:class where TImplementation:class, TTarget;
void Register<TTarget>(TTarget implementation) where TTarget : class;
void RegisterAll<TTarget>() where TTarget : class;
void RegisterAll(Type target);

Registering Open Generics

new in!
Open generics can be registered using the following syntax

Generic Type Resolution

With Bootstrapper you can also use a non container-specific way of resolving your types. Simply call the Resolve and ResolveAll methods of the ContainerExtension as seen below:
var myType = Bootstrapper.ContainerExtension.Resolve<IMyType>();
var myTypes = Bootstrapper.ContainerExtension.ResolveAll<IMyType>();
You could also use the Service Locator Extension

Last edited Jul 1, 2014 at 4:31 AM by luisbocaletti, version 6


No comments yet.