Description

A dependency injection container

Package Information

Version0.2.0 (2017-Mar-08)
Repositoryhttps://github.com/aermicioi/aedi
LicenseBSL-1.0
AuthorsAlexandru Ermicioi
Registered byAlexandru Ermicioi
Dependenciesnone

Installation

To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

Readme

Aedi, a dependency injection framework.

Dub license Travis CI Code cov Dub version Dub downloads

Aedi is a dependency injection framework. It provides a set of containers that do IoC, and an interface to configure application components (structs, objects, etc.)

Aim

The aim of framework is to provide a dependency injection solution that is feature rich, easy to use, easy to learn, and easy to extend up to your needs.

Features

  • Configuration through code or annotations.
  • Modular design.
  • Documentation. Usage tutorial as well api documentation is available (check Documentation section).
  • Unittested.

Installation

Add Aedi as a dependency to a dub project:

Json configuration:

"aedi": "~>0.2.0"

SDL configuration:

dependency "aedi" version="~>0.2.0"

Quickstart

  1. Create a container
  2. Register an application component. Any data (struct, object, union, etc) is treated as application component.
  3. Write a wiring configuration
  4. Repeat process for other components.
  5. Boot container

First of all a container should be created:

	// Containers are responsible for storing, and managing application's components.
    SingletonContainer container = new SingletonContainer;

Next, register component into container:

    container.register!Color

Component is registered by calling .register method on container with type of component. Note, that in example we do not end the statement. That's because component should be configured next:

        .set!"r"(cast(ubyte) 250)
        .set!"g"(cast(ubyte) 210)
        .set!"b"(cast(ubyte) 255);

.set method configures component properties to specific values (setter injection in other words). Note the example ends in ; which means that it's end of statement and Color registration/configuration. Once components are registered and configured, container needs to be booted (instantiated):

    container.instantiate();

Container during boot operation, will do various stuff, including creation and wiring of components between them. It's important to call container.instantiate() after all application's components have been registered into container, otherwise it is not guaranteed that application will work correctly.

Once container is booted, components in it are available for use. To fetch it use locate method like in following example:

container.locate!Color.writeln;

Run example from getting started tutorial:

Color is:	Color(250, 210, 255)

Documentation

All public api documentation is available on aermicioi.github.io/aedi/.

For a more comprehensive understanding of how framework should be used, a set of tutorials are available on github wiki.

Available versions

0.2.0 0.1.0 0.0.1 ~master ~7-simpler-and-better-documentation