README.md

AppBoot

Generic .Net application boostrapper

Overview

A lightweight library that handles the startup of an application and abstracts the composite application as concept. It gives a reusable implementation of the Separate Configuration and Construction from Use principle.

The two most important steps performed at application startup are:

configure the Dependency Injection Container (DIC), and

initialize the Composite Application

Dependency Injection Support

By doing this it enforces consistency on how dependency injection and service location are done in the entire application. It favors constructor dependency injection and encourages programming against interfaces.

It provides annotation based and convention based mechanisms for declaring interface implementations. It is extensible with new custom mechanisms for configuring the DIC.

Annotation Based Configuration

ServiceAttribute is used to decorate a type which should be registered into the DIC as implementation to the specified interface (or contract).

By using the annotations, you can specify on the implementation if its instances should be Singleton or a new instance should be created each time. It can be done by using Lifetime enum on the ServiceAttribute.

publicenumLifetime
{
/// <summary>/// New instances are created each time a new object graph is created./// During the scope of build-up of one object graph the created instances are reused./// </summary>Instance,
/// <summary>/// Always creates a new instance of this class when it is injected as a dependency./// </summary>AlwaysNew,
/// <summary>/// Lives on the application as a singleton instance/// </summary>Application
}

By doing this declaration close to the implementation class, it makes you more careful not to make stateful singletons, or if you do, to synchronize the access in multi-thread environments.

At application startup all the IModule implementations that were registered into the DIC are initialized.

This mechanism, even if it is very simple, it gives a great flexibility in deployment by configuring which modules are available. Multiple logical modules may be defined by implementing IModule, and based on the DIC configuration they are initialized at the application startup.

Getting Started

Remove any references to a Dependency Injection framework and use the AppBoot instead. Currently AppBoot uses Unity Container, but it may be configured to work with any other DIC

Use attribute annotations, convention based or a custom mechanism to define register interface implementation into the underlying DIC

Define logical modules that you want to be initialized at application startup