Restrict access to registration members more tightly

This commit is contained in:
Mike Bierlee 2015-05-03 00:54:31 +02:00
parent eb05f7702f
commit d23230faae
2 changed files with 15 additions and 7 deletions

View file

@ -19,14 +19,23 @@ debug {
}
class Registration {
TypeInfo registeredType = null;
TypeInfo_Class instantiatableType = null;
CreationScope registationScope = null;
private TypeInfo _registeredType = null;
private TypeInfo_Class _instantiatableType = null;
private Registration linkedRegistration;
public @property registeredType() {
return _registeredType;
}
public @property instantiatableType() {
return _instantiatableType;
}
public CreationScope registationScope = null;
this(TypeInfo registeredType, TypeInfo_Class instantiatableType) {
this.registeredType = registeredType;
this.instantiatableType = instantiatableType;
this._registeredType = registeredType;
this._instantiatableType = instantiatableType;
}
public Object getInstance(InstantiationContext context = new InstantiationContext()) {

View file

@ -18,8 +18,7 @@ version(unittest) {
// Test getting instance without scope defined throws exception
unittest {
Registration registration = new Registration(null, null);
registration.registeredType = typeid(TestType);
Registration registration = new Registration(typeid(TestType), null);
assertThrown!(NoScopeDefinedException)(registration.getInstance());
}