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 { 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()) {

View file

@ -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());
} }