poodinis 7.0.1

A dependency injection framework with support for autowiring.


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:

Poodinis Dependency Injection Framework

Version 7.0.1 Copyright 2014-2016 Mike Bierlee Licensed under the terms of the MIT license - See LICENSE.txt

Master: Build Status - Dev: Build Status

Poodinis is a dependency injection framework for the D programming language. It is inspired by the [Spring Framework] and [Hypodermic] IoC container for C++. Poodinis supports registering and resolving classes either by concrete type or interface. Automatic injection of dependencies is supported through the use of UDAs or constructors.

Requires at least a D 2.068.0 compatible compiler Uses the Phobos standard library Can be built with DUB 0.9.24 or higher

Features

  • Member injection: Injection of dependencies in class members of any visibility (public, private, etc.)
  • Constructor injection: Automatic injection of dependencies in class constructors on creation.
  • Type qualifiers: Inject concrete types into members defined only by abstract types.
  • Application contexts: Control the creation of dependencies manually through factory methods.
  • Multi-threadable: Dependency containers return the same dependencies across all threads.
  • Minimal set-up: Creation and injection of conventional classes requires almost no manual dependency configuration.
  • Well-tested: Developed test-driven, a great number of scenarios are tested as part of the test suite.

See the TUTORIAL.md and examples for a complete walkthrough of all features.

Getting started

###DUB Dependency See the Poodinis [DUB project page] for instructions on how to include Poodinis into your project.

###Quickstart The following example shows the typical usage of Poodinis:

import poodinis;

class Driver {}

interface Database {};

class RelationalDatabase : Database {
	private Driver driver;

	this(Driver driver) { // Automatically injected on creation by container
		this.driver = driver;
	}
}

class DataWriter {
	@Autowire
	private Database database; // Automatically injected when class is resolved
}

void main() {
	auto dependencies = new shared DependencyContainer();
	dependencies.register!Driver;
	dependencies.register!DataWriter;
	dependencies.register!(Database, RelationalDatabase);

	auto writer = dependencies.resolve!DataWriter;
}

Dependency set-up can further be reduced by enabling "Register on resolve". For more details and examples, see the examples directory.

Documentation

You can generate Public API documentation from the source code using DUB:

dub build --build=ddox

The documentation can then be found in docs/

History

For a full overview of changes, see CHANGES.md

Future Work

  • Component scan (auto-registration)
  • Phobos collections autowiring
  • Named qualifiers
  • Value type injection

Contributing

Any and all pull requests are welcome! If you (only) want discuss changes before making them, feel free to open an Issue on github. Please develop your changes on (a branch based on) the develop branch. Continuous integration is preferred so feature branches are not neccessary.

Authors:
  • Mike Bierlee
Dependencies:
none
Versions:
9.0.0 2023-Mar-13
8.2.0 2023-Mar-13
8.1.3 2022-Oct-26
8.1.2 2022-Feb-17
8.1.1 2021-Aug-24
Show all 40 versions
Download Stats:
  • 6 downloads today

  • 46 downloads this week

  • 136 downloads this month

  • 23399 downloads total

Score:
3.5
Short URL:
poodinis.dub.pm