A dependency injection container
To use this package, put the following dependency into your project's dependencies section:
Aedi, a dependency injection framework.
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.)
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.
- Configuration through code or annotations.
- Modular design.
- Documentation. Usage tutorial as well api documentation is available (check Documentation section).
Add Aedi as a dependency to a dub project:
dependency "aedi" version="~>0.2.0"
- Create a container
- Register an application component. Any data (struct, object, union, etc) is treated as application component.
- Write a wiring configuration
- Repeat process for other components.
- 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:
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
.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 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:
Run example from getting started tutorial:
Color is: Color(250, 210, 255)
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.
- Registered by Alexandru Ermicioi
0 downloads today
0 downloads this week
2 downloads this month
70 downloads total