mirror of
https://github.com/mbierlee/poodinis.git
synced 2024-11-15 04:04:01 +01:00
Check type at compile-time
This commit is contained in:
parent
4be09dc821
commit
9c749c0cb6
|
@ -30,7 +30,8 @@ public void autowire(Type)(DependencyContainer container, Type instance) {
|
||||||
foreach (member ; __traits(allMembers, Type)) {
|
foreach (member ; __traits(allMembers, Type)) {
|
||||||
static if(__traits(compiles, __traits( getMember, Type, member )) && __traits(compiles, __traits(getAttributes, __traits(getMember, Type, member )))) {
|
static if(__traits(compiles, __traits( getMember, Type, member )) && __traits(compiles, __traits(getAttributes, __traits(getMember, Type, member )))) {
|
||||||
foreach(attribute; __traits(getAttributes, __traits(getMember, Type, member))) {
|
foreach(attribute; __traits(getAttributes, __traits(getMember, Type, member))) {
|
||||||
if (is(attribute : Autowire) && __traits(getMember, instance, member) is null){
|
static if (is(attribute : Autowire)) {
|
||||||
|
if (__traits(getMember, instance, member) is null) {
|
||||||
alias TypeTuple!(__traits(getMember, instance, member)) memberReference;
|
alias TypeTuple!(__traits(getMember, instance, member)) memberReference;
|
||||||
auto autowirableInstance = container.resolve!(typeof(memberReference));
|
auto autowirableInstance = container.resolve!(typeof(memberReference));
|
||||||
debug {
|
debug {
|
||||||
|
@ -45,6 +46,7 @@ public void autowire(Type)(DependencyContainer container, Type instance) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mixin template AutowireConstructor() {
|
mixin template AutowireConstructor() {
|
||||||
public this() {
|
public this() {
|
||||||
|
|
Loading…
Reference in a new issue