mirror of
https://github.com/mbierlee/poodinis.git
synced 2024-11-15 04:04:01 +01:00
Autoformat container.d
This commit is contained in:
parent
04a30db126
commit
e1cb511178
|
@ -181,7 +181,7 @@ synchronized class DependencyContainer
|
||||||
* See_Also: singleInstance, newInstance, existingInstance, RegistrationOption
|
* See_Also: singleInstance, newInstance, existingInstance, RegistrationOption
|
||||||
*/
|
*/
|
||||||
public Registration register(SuperType, ConcreteType:
|
public Registration register(SuperType, ConcreteType:
|
||||||
SuperType)(RegistrationOption options = RegistrationOption.none)
|
SuperType)(RegistrationOption options = RegistrationOption.none)
|
||||||
if (!is(ConcreteType == struct))
|
if (!is(ConcreteType == struct))
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -202,7 +202,7 @@ synchronized class DependencyContainer
|
||||||
|
|
||||||
auto instanceFactory = new ConstructorInjectingInstanceFactory!ConcreteType(this);
|
auto instanceFactory = new ConstructorInjectingInstanceFactory!ConcreteType(this);
|
||||||
auto newRegistration = new AutowiredRegistration!ConcreteType(registeredType,
|
auto newRegistration = new AutowiredRegistration!ConcreteType(registeredType,
|
||||||
instanceFactory, this);
|
instanceFactory, this);
|
||||||
newRegistration.initializeFactoryType().singleInstance();
|
newRegistration.initializeFactoryType().singleInstance();
|
||||||
|
|
||||||
static if (!is(SuperType == ConcreteType))
|
static if (!is(SuperType == ConcreteType))
|
||||||
|
@ -220,7 +220,7 @@ synchronized class DependencyContainer
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool hasOption(OptionType)(OptionType options,
|
private bool hasOption(OptionType)(OptionType options,
|
||||||
OptionType persistentOptions, OptionType option)
|
OptionType persistentOptions, OptionType option)
|
||||||
{
|
{
|
||||||
return ((options | persistentOptions) & option) != 0;
|
return ((options | persistentOptions) & option) != 0;
|
||||||
}
|
}
|
||||||
|
@ -299,7 +299,7 @@ synchronized class DependencyContainer
|
||||||
* You need to use the resolve method which allows you to specify a qualifier.
|
* You need to use the resolve method which allows you to specify a qualifier.
|
||||||
*/
|
*/
|
||||||
public RegistrationType resolve(RegistrationType)(
|
public RegistrationType resolve(RegistrationType)(
|
||||||
ResolveOption resolveOptions = ResolveOption.none)
|
ResolveOption resolveOptions = ResolveOption.none)
|
||||||
if (!is(RegistrationType == struct))
|
if (!is(RegistrationType == struct))
|
||||||
{
|
{
|
||||||
return resolve!(RegistrationType, RegistrationType)(resolveOptions);
|
return resolve!(RegistrationType, RegistrationType)(resolveOptions);
|
||||||
|
@ -332,7 +332,7 @@ synchronized class DependencyContainer
|
||||||
* ---
|
* ---
|
||||||
*/
|
*/
|
||||||
public QualifierType resolve(RegistrationType, QualifierType:
|
public QualifierType resolve(RegistrationType, QualifierType:
|
||||||
RegistrationType)(ResolveOption resolveOptions = ResolveOption.none)
|
RegistrationType)(ResolveOption resolveOptions = ResolveOption.none)
|
||||||
if (!is(QualifierType == struct))
|
if (!is(QualifierType == struct))
|
||||||
{
|
{
|
||||||
TypeInfo resolveType = typeid(RegistrationType);
|
TypeInfo resolveType = typeid(RegistrationType);
|
||||||
|
@ -365,7 +365,7 @@ synchronized class DependencyContainer
|
||||||
}
|
}
|
||||||
|
|
||||||
Registration registration = getQualifiedRegistration(resolveType,
|
Registration registration = getQualifiedRegistration(resolveType,
|
||||||
qualifierType, cast(Registration[])*candidates);
|
qualifierType, cast(Registration[])*candidates);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -393,7 +393,7 @@ synchronized class DependencyContainer
|
||||||
{
|
{
|
||||||
autowireStack ~= cast(shared(Registration)) registration;
|
autowireStack ~= cast(shared(Registration)) registration;
|
||||||
instance = cast(QualifierType) registration.getInstance(
|
instance = cast(QualifierType) registration.getInstance(
|
||||||
new AutowireInstantiationContext());
|
new AutowireInstantiationContext());
|
||||||
autowireStack = autowireStack[0 .. $ - 1];
|
autowireStack = autowireStack[0 .. $ - 1];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -423,7 +423,7 @@ synchronized class DependencyContainer
|
||||||
* ---
|
* ---
|
||||||
*/
|
*/
|
||||||
public RegistrationType[] resolveAll(RegistrationType)(
|
public RegistrationType[] resolveAll(RegistrationType)(
|
||||||
ResolveOption resolveOptions = ResolveOption.none)
|
ResolveOption resolveOptions = ResolveOption.none)
|
||||||
{
|
{
|
||||||
RegistrationType[] instances;
|
RegistrationType[] instances;
|
||||||
TypeInfo resolveType = typeid(RegistrationType);
|
TypeInfo resolveType = typeid(RegistrationType);
|
||||||
|
@ -449,7 +449,7 @@ synchronized class DependencyContainer
|
||||||
}
|
}
|
||||||
|
|
||||||
private Registration getQualifiedRegistration(TypeInfo resolveType,
|
private Registration getQualifiedRegistration(TypeInfo resolveType,
|
||||||
TypeInfo qualifierType, Registration[] candidates)
|
TypeInfo qualifierType, Registration[] candidates)
|
||||||
{
|
{
|
||||||
if (resolveType == qualifierType)
|
if (resolveType == qualifierType)
|
||||||
{
|
{
|
||||||
|
@ -457,8 +457,8 @@ synchronized class DependencyContainer
|
||||||
{
|
{
|
||||||
string candidateList = candidates.toConcreteTypeListString();
|
string candidateList = candidates.toConcreteTypeListString();
|
||||||
throw new ResolveException(
|
throw new ResolveException(
|
||||||
"Multiple qualified candidates available: " ~ candidateList ~ ". Please use a qualifier.",
|
"Multiple qualified candidates available: " ~ candidateList ~ ". Please use a qualifier.",
|
||||||
resolveType);
|
resolveType);
|
||||||
}
|
}
|
||||||
|
|
||||||
return candidates[0];
|
return candidates[0];
|
||||||
|
@ -474,9 +474,9 @@ synchronized class DependencyContainer
|
||||||
mixin(createImportsString!Type);
|
mixin(createImportsString!Type);
|
||||||
enum QualifiedName = fullyQualifiedName!Type ~ `.` ~ memberName;
|
enum QualifiedName = fullyQualifiedName!Type ~ `.` ~ memberName;
|
||||||
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"
|
||||||
&& isFunction!(mixin(QualifiedName))
|
&& isFunction!(mixin(QualifiedName))
|
||||||
&& 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