mirror of
https://github.com/mbierlee/poodinis.git
synced 2024-11-15 04:04:01 +01:00
Fix check on whether a member was a function
Checks on some kinds of members, such as constants, would trip up with the isCallable trait.
This commit is contained in:
parent
10d24eb9fb
commit
925c3f4119
|
@ -264,9 +264,10 @@ class AutowiredRegistration(RegistrationType : Object) : Registration {
|
||||||
private void delegate() getPreDestructor(RegistrationType instance) {
|
private void delegate() getPreDestructor(RegistrationType instance) {
|
||||||
void delegate() preDestructor = null;
|
void delegate() preDestructor = null;
|
||||||
foreach (memberName; __traits(allMembers, RegistrationType)) {
|
foreach (memberName; __traits(allMembers, RegistrationType)) {
|
||||||
|
mixin(`import ` ~ moduleName!RegistrationType ~ `;`);
|
||||||
static if (__traits(compiles, __traits(getProtection, __traits(getMember, instance, memberName)))
|
static if (__traits(compiles, __traits(getProtection, __traits(getMember, instance, memberName)))
|
||||||
&& __traits(getProtection, __traits(getMember, instance, memberName)) == "public"
|
&& __traits(getProtection, __traits(getMember, instance, memberName)) == "public"
|
||||||
&& isCallable!(__traits(getMember, instance, memberName))
|
&& isFunction!(mixin(fullyQualifiedName!RegistrationType ~ `.` ~ memberName))
|
||||||
&& hasUDA!(__traits(getMember, instance, memberName), PreDestroy)) {
|
&& hasUDA!(__traits(getMember, instance, memberName), PreDestroy)) {
|
||||||
preDestructor = &__traits(getMember, instance, memberName);
|
preDestructor = &__traits(getMember, instance, memberName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -390,9 +390,10 @@ synchronized class DependencyContainer {
|
||||||
|
|
||||||
private void callPostConstructors(Type)(Type instance) {
|
private void callPostConstructors(Type)(Type instance) {
|
||||||
foreach (memberName; __traits(allMembers, Type)) {
|
foreach (memberName; __traits(allMembers, Type)) {
|
||||||
|
mixin(`import ` ~ moduleName!Type ~ `;`);
|
||||||
static if (__traits(compiles, __traits(getProtection, __traits(getMember, instance, memberName)))
|
static if (__traits(compiles, __traits(getProtection, __traits(getMember, instance, memberName)))
|
||||||
&& __traits(getProtection, __traits(getMember, instance, memberName)) == "public"
|
&& __traits(getProtection, __traits(getMember, instance, memberName)) == "public"
|
||||||
&& isCallable!(__traits(getMember, instance, memberName))
|
&& isFunction!(mixin(fullyQualifiedName!Type ~ `.` ~ memberName))
|
||||||
&& hasUDA!(__traits(getMember, instance, memberName), PostConstruct)) {
|
&& hasUDA!(__traits(getMember, instance, memberName), PostConstruct)) {
|
||||||
__traits(getMember, instance, memberName)();
|
__traits(getMember, instance, memberName)();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue