mirror of
https://github.com/mbierlee/poodinis.git
synced 2024-11-15 12:14:01 +01:00
Restrict access to registration members more tightly
This commit is contained in:
parent
eb05f7702f
commit
d23230faae
|
@ -19,14 +19,23 @@ debug {
|
||||||
}
|
}
|
||||||
|
|
||||||
class Registration {
|
class Registration {
|
||||||
TypeInfo registeredType = null;
|
private TypeInfo _registeredType = null;
|
||||||
TypeInfo_Class instantiatableType = null;
|
private TypeInfo_Class _instantiatableType = null;
|
||||||
CreationScope registationScope = null;
|
|
||||||
private Registration linkedRegistration;
|
private Registration linkedRegistration;
|
||||||
|
|
||||||
|
public @property registeredType() {
|
||||||
|
return _registeredType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @property instantiatableType() {
|
||||||
|
return _instantiatableType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CreationScope registationScope = null;
|
||||||
|
|
||||||
this(TypeInfo registeredType, TypeInfo_Class instantiatableType) {
|
this(TypeInfo registeredType, TypeInfo_Class instantiatableType) {
|
||||||
this.registeredType = registeredType;
|
this._registeredType = registeredType;
|
||||||
this.instantiatableType = instantiatableType;
|
this._instantiatableType = instantiatableType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getInstance(InstantiationContext context = new InstantiationContext()) {
|
public Object getInstance(InstantiationContext context = new InstantiationContext()) {
|
||||||
|
|
|
@ -18,8 +18,7 @@ version(unittest) {
|
||||||
|
|
||||||
// Test getting instance without scope defined throws exception
|
// Test getting instance without scope defined throws exception
|
||||||
unittest {
|
unittest {
|
||||||
Registration registration = new Registration(null, null);
|
Registration registration = new Registration(typeid(TestType), null);
|
||||||
registration.registeredType = typeid(TestType);
|
|
||||||
assertThrown!(NoScopeDefinedException)(registration.getInstance());
|
assertThrown!(NoScopeDefinedException)(registration.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue