Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Dependency injection framework for D with support for autowiring.

License

NotificationsYou must be signed in to change notification settings

mbierlee/poodinis

Repository files navigation

Version 9.0.1
Copyright 2014-2025 Mike Bierlee
Licensed under the terms of the MIT license - SeeLICENSE.txt

DUB PackageCI

Poodinis is a dependency injection framework for the D programming language. It is inspired by theSpring Framework andHypodermic 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.086.1 compatible compiler
Uses the Phobos standard library

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.
  • Value injection: Value-types such as primitives or structs can be injected using custom value injectors.
  • 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 theTUTORIAL.md andexamples for a complete walkthrough of all features.

Getting started

DUB Dependency

See the PoodinisDUB project page for instructions on how to include Poodinis into your project.

Quickstart

The following example shows the typical usage of Poodinis:

import poodinis;classDriver {}interfaceDatabase {}classRelationalDatabase :Database {private Driver driver;this(Driver driver) {// Automatically injected on creation by containerthis.driver = driver;}}classDataWriter {@InjectprivateDatabase database;// Automatically injected when class is resolved}voidmain() {auto dependencies =newshared 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 theexamples directory.

Documentation

You can find the public API documentationhere.

Alternatively you can generate 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, seeCHANGES.md

Value Injectors

Poodinis doesn't come with implementations of value injectors. Value injectors are available in separate projects:

Have you made any or do you know of any? Please add them to this section via a pull request or open an issue.

Projects Using Poodinis

  • Hunt Framework: A Web framework for D Programming Language. Full-stack high-performance.
  • Eloquent: A lightweight web application written in D
  • ioc: Slow approach to Inversion of Control in D2 language

Future Work

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

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.


[8]ページ先頭

©2009-2025 Movatter.jp