This project is read-only.

Bootstrapper configuration

Lambda Container (LC) is designed to be easy to use with a minimum of setup code.

Setting up the registration operation

The way registrations are added can be configured as illustrated below:
   .ConfigureContainerSettings(fun config -> config.RegistrationCollisionMode <- RegistrationCollisionModes.Accept)

config.RegistrationCollisionMode (Default: Fail)

Defines how the registration engine should react in the case of multiple registrations for the same output/name combination.
  • Fail: An exception is thrown and the bootstrapper terminates
  • Ignore: The existing registration is kept and the incoming registration is ignored.
  • Override: The existing registration is replaced by the incoming registration.

Setting up the assembly scanner

Assembly scanning using Lambda Container Registries is enabled by default, since it is the recommended way to setup the registrations. The following shows how to configure the assembly scanner.:

Code examples in F#
//Example 1: Use default bootstrapper configuration and with the assembly scanner enabled
let bs1 = LambdaContainerBootstrapper.Create()

//Example 2: Create with a modified configuration
let bs2 = LambdaContainerBootstrapper
      fun (config : LambdaContainerConfiguration) -> 
         config.RegistryFileNameCondition <- (fun fileInfo -> true)
         config.RegistryScannerBaseDir <- "<some other dir than app domain base dir>"
         config.Enabled <- true)

config.RegistryFileNameCondition(Default: accept all)

Provide a lambda function that selects a subset of assemblies to evaluate when running the bootstrapper. All files, which do not match the specified condition, are not checked for registries.

config.RegistryScannerBaseDir (Default: AppDomain.Current.BaseDir)

Determine search root for the registry file traverser.

config.Enabled (Default: true)

Enable/Disable assembly scanning

Adding initial registrations

Whether or not assembly scanning is used, it is possible to add a number of (or all) registrations through the pre-bootstrapping registration API, which use the same registration builder API as the one provided by the assembly scanner.
These registrations are applied before any assembly scanned registries get to apply theirs so it is a good way to add default registrations for specific services (requires that"RegistrationCollisionMode" is set to "Accept")
Code example in F#
//Example registering by factory and by type
                        fun r -> r.Record<ITypeMappingRegistrations>(
                          fun c -> c.Build()
                            .Register<IAFirstClass, AFirstClass>()
                            .Register<IASecondClass, ASecondClass>() |> ignore) |> ignore)

Notice that execution of the registration lambdas is deferred until the bootstrapper is actually executed through the "Run" function.

Read Lambda Container Registries for full details on the different registration builder API's and details about the registration builder API.

Building the container

After running the bootstrapper's "Run" method, a new instance of the LC is returned. For all instances created by the LC, it will be possible to use dependency injection to get a reference to it.

Code example in F#
      // Run the Bootstrapper
      let container = bs1.Run()

That's it. The container is now created and ready serve.

Last edited Mar 27, 2016 at 9:55 AM by Remboel, version 24