This project is read-only.

Bootstrapper 2.0 guide


Bootstrapper relies heavily on the plugin pattern for extensibility. In Bootstrapper each plugin is called an extension and its usually packaged in it's own assembly. To use an extension you need to add a reference to the extension's assembly and then you can use the Extension method as seen below
Bootstrapper.With.Extension(new AutoMapperExtension()).And.Extension(new NinjectExtension()).Start()
For convenience all the bootstrapper extensions provide static methods that can be used instead of using the Extension() syntax


When the Start method is invoked. Bootstrapper will scan the list of extensions that were declared and will invoke the run method of each one in the order that they were declared. This is important to note if, for example you want your startup tasks to use an initialized container, make sure to declare the container extension before the startup task extension. For example
Some extensions like StartupTask and Automapper will make use of the container if it is declared and initialized to get a list of maps or registration classes. However, if the container is not present or not initialized then these extensions will use reflection to find maps and registration. That means that both of these statements will succeed.
Calling the Reset() method will call the reset method of each extension in the reverse order that they were added. Again, if you have a startup task that will use the container in the Reset method then make sure that the Container gets added before the StartupTasks extension like below:
//... later


Bootstrapper scans the application's assemblies looking for implementations of specific interfaces like IMapCreator, IStartupTask, etc.. The default behavior is to scan all the loaded assemblies, so in most cases you don't have to indicate to Bootstrapper where to look for things. However, you can specify specific assemblies to include or exclude in bootstrapper's execution.
To exclude an assembly or assemblies you only need to specify the assembly name or part of it with the Excluding syntax as seen in the example:
    Assembly("log4net").        //excludes log4net.dll
    AndAssembly("Microsoft").   //excludes all assemblies 
                                //where the name starts with
                                //Microsoft like Microsoft.Csharp
Many extensions exclude assemblies they depend on to improve the performance of Bootstrapper. For example, the AutoMapper extension excludes Automapper.dll, The Windsor extension excludes all assemblies starting with "Castle", etc.

In the case where an assembly containing maps or tasks or registration is not loaded when Bootstrapper executes it might be necessary to use the Including syntax to add it to the list of assemblies that Bootstrapper will scan. Unlike Excluding(), Including doesn't take a name or part of it, instead it expects an assembly. For example:

New in!
Additionally, Bootstrapper can be told exactly where to look for things using the IncludingOnly syntax. Like Including(), this method expects an actual assembly. For example:

New in!!
By default Bootstrapper scans the Loaded Assemblies to look for types. However, in the case of web applications, this behavior can become problematic when IIS recycles. For that reason Bootstrapper now provides an option to specify where to look for types with the LookForTypesIn syntax.
By the default the value is LoadedAssemblies but for Web projects (Asp.Net, Mvc, WCF,etc.) it is possible to use the value ReferencedAssemblies. For example:
//Loaded Assemblies
//Same effect as
//Only for Web projects (Asp.Net, MVC, Wcf, etc.)

The Extensions

Details on how to use each extension can be found by clicking on the following links

Last edited Jul 29, 2013 at 4:30 AM by luisbocaletti, version 17


No comments yet.