aedi ~7-simpler-and-better-documentation

A dependency injection container


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

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.

Authors:
  • Alexandru Ermicioi
Dependencies:
none
Versions:
1.0.0 2018-Oct-06
0.5.0 2018-Mar-10
0.4.0 2018-Feb-24
0.3.0 2017-Aug-18
0.2.0 2017-Mar-08
Show all 9 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 392 downloads total

Score:
1.7
Short URL:
aedi.dub.pm