Created
December 26, 2014 16:31
-
-
Save raphaelgabbarelli/026b138bb84f98094f1e to your computer and use it in GitHub Desktop.
getting an instance of a type from the IoC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.get = function(key){ | |
for(var i = 0; i < self.dependencies.length; i++){ | |
var dep = self.dependencies[i]; | |
if(dep.key === key){ | |
var deps = []; | |
if(dep.dependency.$deps != null){ | |
for(var d = 0; d < dep.dependency.$deps.length; d++){ | |
deps.push(self.get(dep.dependency.$deps[d])); | |
} | |
} | |
return dep.dependency.$ctor.apply(null, deps); | |
} | |
} | |
return null; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment