diff --git a/src/hex/module/dependency/IRuntimeDependencies.hx b/src/hex/module/dependency/IRuntimeDependencies.hx index 5ea56e4..f706253 100644 --- a/src/hex/module/dependency/IRuntimeDependencies.hx +++ b/src/hex/module/dependency/IRuntimeDependencies.hx @@ -1,11 +1,13 @@ package hex.module.dependency; +import hex.di.mapping.Mapping; + /** * @author Francis Bourre */ interface IRuntimeDependencies { function hasMappedDependencies() : Bool; - function addMappedDependencies( serviceDependencies : Array> ) : Void; - function getMappedDependencies() : Array>; + function addMappedDependencies( serviceDependencies : Array ) : Void; + function getMappedDependencies() : Array; } \ No newline at end of file diff --git a/src/hex/module/dependency/RuntimeDependencies.hx b/src/hex/module/dependency/RuntimeDependencies.hx index a628c9a..e66e906 100644 --- a/src/hex/module/dependency/RuntimeDependencies.hx +++ b/src/hex/module/dependency/RuntimeDependencies.hx @@ -1,29 +1,31 @@ package hex.module.dependency; +import hex.di.mapping.Mapping; + /** * ... * @author Francis Bourre */ class RuntimeDependencies implements IRuntimeDependencies { - var _mappedDependencies : Array>; + var _mappedDependencies : Array; public function new() { } - public function addMappedDependencies( serviceDependencies : Array> ) : Void + public function addMappedDependencies( serviceDependencies : Array ) : Void { if ( this._mappedDependencies == null ) { - this._mappedDependencies = new Array>(); + this._mappedDependencies = new Array(); } this._mappedDependencies = this._mappedDependencies.concat( serviceDependencies ); } - public function getMappedDependencies() : Array> + public function getMappedDependencies() : Array { return this._mappedDependencies; } diff --git a/src/hex/module/dependency/RuntimeDependencyChecker.hx b/src/hex/module/dependency/RuntimeDependencyChecker.hx index 0e0c0ad..3646d97 100644 --- a/src/hex/module/dependency/RuntimeDependencyChecker.hx +++ b/src/hex/module/dependency/RuntimeDependencyChecker.hx @@ -21,13 +21,13 @@ class RuntimeDependencyChecker { if ( dependencies.hasMappedDependencies() ) { - var mappedDependencies : Array> = dependencies.getMappedDependencies(); + var mappedDependencies = dependencies.getMappedDependencies(); for ( dependency in mappedDependencies ) { - if ( !injector.hasMapping( dependency ) ) + if ( !injector.hasMapping( dependency.type, dependency.name ) ) { - throw new RuntimeDependencyException( "'" + dependency + "' class dependency is not available during '" + Stringifier.stringify( module ) + "' initialisation." ); + throw new RuntimeDependencyException( "'" + dependency + "' dependency is not available during '" + Stringifier.stringify( module ) + "' initialisation." ); } } } diff --git a/test/hex/module/ModuleTest.hx b/test/hex/module/ModuleTest.hx index 6bcdc9c..9e04cbe 100644 --- a/test/hex/module/ModuleTest.hx +++ b/test/hex/module/ModuleTest.hx @@ -6,6 +6,7 @@ import hex.di.IBasicInjector; import hex.di.IDependencyInjector; import hex.di.Injector; import hex.di.error.MissingMappingException; +import hex.di.mapping.MappingDefinition; import hex.domain.DomainExpert; import hex.error.Exception; import hex.error.IllegalStateException; @@ -285,7 +286,7 @@ private class MockModuleForTestingRuntimeDependencies extends Module override function _getRuntimeDependencies() : IRuntimeDependencies { var rd : RuntimeDependencies = new RuntimeDependencies(); - rd.addMappedDependencies( [IService]); + rd.addMappedDependencies( [ new MappingDefinition( IService ) ]); return rd; } }