From d23230faaec02fa7b51cf8eb4017d9fe3414e1bc Mon Sep 17 00:00:00 2001 From: Mike Bierlee Date: Sun, 3 May 2015 00:54:31 +0200 Subject: [PATCH] Restrict access to registration members more tightly --- source/poodinis/registration.d | 19 ++++++++++++++----- test/poodinis/registrationtest.d | 3 +-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/source/poodinis/registration.d b/source/poodinis/registration.d index 7cc904c..353aa7e 100644 --- a/source/poodinis/registration.d +++ b/source/poodinis/registration.d @@ -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()) { diff --git a/test/poodinis/registrationtest.d b/test/poodinis/registrationtest.d index 36bc257..3017a9c 100644 --- a/test/poodinis/registrationtest.d +++ b/test/poodinis/registrationtest.d @@ -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()); }