mirror of
https://github.com/mbierlee/poodinis.git
synced 2024-11-15 04:04:01 +01:00
Accept defeat and recognize resolve by supertype/interface bug
For now....
This commit is contained in:
parent
af7d6a7872
commit
f97a689f29
|
@ -107,7 +107,7 @@ assert(exampleInstance.dependency !is null);
|
||||||
```
|
```
|
||||||
At the moment, it is only possible to autowire public members or properties.
|
At the moment, it is only possible to autowire public members or properties.
|
||||||
|
|
||||||
Dependencies are automatically autowired when a class is resolved. So when you register ExampleClassB, its member, *dependency*, is automatically injected:
|
Dependencies are automatically autowired when a class is resolved. So when you register ExampleClassB, its member, *dependency*, is automatically autowired:
|
||||||
```d
|
```d
|
||||||
container.register!ExampleClassA;
|
container.register!ExampleClassA;
|
||||||
container.register!ExampleClassB;
|
container.register!ExampleClassB;
|
||||||
|
@ -122,6 +122,7 @@ Poodinis can autowire circular dependencies when they are registered with single
|
||||||
Known issues
|
Known issues
|
||||||
------------
|
------------
|
||||||
* Due to preventive measures of recursion issues in circular dependencies, registrations which are supposed to yield new instances will not autowire classes for which a circular dependency is detected. A new instance will be resolved but the instance's members will not be autowired.
|
* Due to preventive measures of recursion issues in circular dependencies, registrations which are supposed to yield new instances will not autowire classes for which a circular dependency is detected. A new instance will be resolved but the instance's members will not be autowired.
|
||||||
|
* Resolving a class registered by supertype or interface will only autowire the members inherited from its supertype and in the case of interfaces nothing at all.
|
||||||
|
|
||||||
Future Work
|
Future Work
|
||||||
-----------
|
-----------
|
||||||
|
|
|
@ -73,6 +73,14 @@ version(unittest) {
|
||||||
public Bittie bittie;
|
public Bittie bittie;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface SuperInterface {
|
||||||
|
}
|
||||||
|
|
||||||
|
class SuperImplementation : SuperInterface {
|
||||||
|
@Autowire
|
||||||
|
public Banana banana;
|
||||||
|
}
|
||||||
|
|
||||||
// Test register concrete type
|
// Test register concrete type
|
||||||
unittest {
|
unittest {
|
||||||
auto container = new Container();
|
auto container = new Container();
|
||||||
|
@ -224,4 +232,15 @@ version(unittest) {
|
||||||
|
|
||||||
assert(ittie.bittie.banana.bittie.banana is null, "Autowiring deep dependencies with newInstance scope autowired a reoccuring type.");
|
assert(ittie.bittie.banana.bittie.banana is null, "Autowiring deep dependencies with newInstance scope autowired a reoccuring type.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test autowiring type registered by interface
|
||||||
|
unittest {
|
||||||
|
auto container = new Container();
|
||||||
|
container.register!Banana;
|
||||||
|
container.register!(SuperInterface, SuperImplementation);
|
||||||
|
|
||||||
|
SuperImplementation superInstance = cast(SuperImplementation) container.resolve!SuperInterface;
|
||||||
|
|
||||||
|
assert(superInstance.banana is null, "Autowire instance which was resolved by interface type, which was not expected to be possible");
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue