mirror of
https://github.com/mbierlee/poodinis.git
synced 2024-11-15 04:04:01 +01:00
parent
dc1cf04e96
commit
e1f0cca5c5
|
@ -1,5 +1,9 @@
|
|||
Poodinis Changelog
|
||||
==================
|
||||
**Version 7.0.1**
|
||||
* FIX codegeneration of constructor injection factories for constructors with dependencies from foreign modules,
|
||||
such as modules from other libraries (Issue #12).
|
||||
|
||||
**Version 7.0.0**
|
||||
This version introduces changes which might be incompatible with your current codebase
|
||||
* ADD constructor injection. Injection is done automatically on resolve. See tutorial and examples for more details.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
Poodinis Dependency Injection Framework
|
||||
=======================================
|
||||
Version 7.0.0
|
||||
Version 7.0.1
|
||||
Copyright 2014-2016 Mike Bierlee
|
||||
Licensed under the terms of the MIT license - See [LICENSE.txt](LICENSE.txt)
|
||||
|
||||
|
|
|
@ -107,6 +107,14 @@ class ConstructorInjectingInstanceFactory(InstanceType) : InstanceFactory {
|
|||
return argumentList;
|
||||
}
|
||||
|
||||
private static string createImportList(Params...)() {
|
||||
string importList = "";
|
||||
foreach(param; Params) {
|
||||
importList ~= "import " ~ moduleName!param ~ ";";
|
||||
}
|
||||
return importList;
|
||||
}
|
||||
|
||||
private static bool parametersAreValid(Params...)() {
|
||||
bool isValid = true;
|
||||
foreach(param; Params) {
|
||||
|
@ -130,6 +138,7 @@ class ConstructorInjectingInstanceFactory(InstanceType) : InstanceFactory {
|
|||
isBeingInjected = true;
|
||||
mixin(`
|
||||
import ` ~ moduleName!InstanceType ~ `;
|
||||
` ~ createImportList!(Parameters!ctor) ~ `
|
||||
instance = new ` ~ fullyQualifiedName!InstanceType ~ `(` ~ createArgumentList!(Parameters!ctor) ~ `);
|
||||
`);
|
||||
isBeingInjected = false;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
import poodinis;
|
||||
import poodinis.test.foreignDependencies;
|
||||
|
||||
import std.exception;
|
||||
import core.thread;
|
||||
|
@ -219,6 +220,10 @@ version(unittest) {
|
|||
this(Paper paper) {}
|
||||
}
|
||||
|
||||
class Hello {
|
||||
this(Ola ola) {}
|
||||
}
|
||||
|
||||
// Test register concrete type
|
||||
unittest {
|
||||
auto container = new shared DependencyContainer();
|
||||
|
@ -734,4 +739,12 @@ version(unittest) {
|
|||
|
||||
assertThrown!InstanceCreationException(container.resolve!Rock);
|
||||
}
|
||||
|
||||
// Test injection of foreign dependency in constructor
|
||||
unittest {
|
||||
auto container = new shared DependencyContainer();
|
||||
container.register!Ola;
|
||||
container.register!Hello;
|
||||
container.resolve!Hello;
|
||||
}
|
||||
}
|
||||
|
|
10
test/poodinis/foreigndependencies.d
Normal file
10
test/poodinis/foreigndependencies.d
Normal file
|
@ -0,0 +1,10 @@
|
|||
/**
|
||||
* Poodinis Dependency Injection Framework
|
||||
* Copyright 2014-2016 Mike Bierlee
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* The full terms of the license can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
module poodinis.test.foreignDependencies;
|
||||
|
||||
class Ola {}
|
Loading…
Reference in a new issue