mirror of
https://github.com/mbierlee/poodinis.git
synced 2024-11-15 04:04:01 +01:00
Use getOverloads in registerContextComponents (fix #43)
This commit is contained in:
parent
b8caa00be1
commit
6d1bf44d28
|
@ -71,16 +71,17 @@ public void registerContext(Context : ApplicationContext)(shared(DependencyConta
|
||||||
public void registerContextComponents(ApplicationContextType : ApplicationContext)(
|
public void registerContextComponents(ApplicationContextType : ApplicationContext)(
|
||||||
ApplicationContextType context, shared(DependencyContainer) container)
|
ApplicationContextType context, shared(DependencyContainer) container)
|
||||||
{
|
{
|
||||||
foreach (member; __traits(allMembers, ApplicationContextType))
|
foreach (memberName; __traits(allMembers, ApplicationContextType))
|
||||||
{
|
{
|
||||||
static if (__traits(getProtection, __traits(getMember, context,
|
foreach (overload; __traits(getOverloads, context, memberName))
|
||||||
member)) == "public" && hasUDA!(__traits(getMember, context, member), Component))
|
|
||||||
{
|
{
|
||||||
auto factoryMethod = &__traits(getMember, context, member);
|
static if (__traits(getProtection, overload) == "public" && hasUDA!(overload, Component))
|
||||||
|
{
|
||||||
|
auto factoryMethod = &__traits(getMember, context, memberName);
|
||||||
Registration registration = null;
|
Registration registration = null;
|
||||||
auto createsSingleton = CreatesSingleton.yes;
|
auto createsSingleton = CreatesSingleton.yes;
|
||||||
|
|
||||||
foreach (attribute; __traits(getAttributes, __traits(getMember, context, member)))
|
foreach (attribute; __traits(getAttributes, overload))
|
||||||
{
|
{
|
||||||
static if (is(attribute == RegisterByType!T, T))
|
static if (is(attribute == RegisterByType!T, T))
|
||||||
{
|
{
|
||||||
|
@ -99,7 +100,12 @@ public void registerContextComponents(ApplicationContextType : ApplicationContex
|
||||||
}
|
}
|
||||||
|
|
||||||
registration.instanceFactory.factoryParameters = InstanceFactoryParameters(
|
registration.instanceFactory.factoryParameters = InstanceFactoryParameters(
|
||||||
registration.instanceType, createsSingleton, null, factoryMethod);
|
registration.instanceType,
|
||||||
|
createsSingleton,
|
||||||
|
null,
|
||||||
|
factoryMethod
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue