Accept defeat and recognize resolve by supertype/interface bug

For now....
This commit is contained in:
Mike Bierlee 2014-06-13 23:49:34 +02:00
parent af7d6a7872
commit f97a689f29
2 changed files with 22 additions and 2 deletions

View file

@ -107,7 +107,7 @@ assert(exampleInstance.dependency !is null);
```
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
container.register!ExampleClassA;
container.register!ExampleClassB;
@ -121,7 +121,8 @@ Poodinis can autowire circular dependencies when they are registered with single
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
-----------

View file

@ -73,6 +73,14 @@ version(unittest) {
public Bittie bittie;
}
interface SuperInterface {
}
class SuperImplementation : SuperInterface {
@Autowire
public Banana banana;
}
// Test register concrete type
unittest {
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.");
}
// 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");
}
}