コード例 #1
0
ファイル: container.py プロジェクト: mikhtonyuk/pyhk2
    def getAll(self, what):
        log.debug("Resolving all '%s'", what)

        ip = inject_param(allof(what))
        bound = self._binds.getAll(what)

        ctxz = [InjectionContext(self._binds, b, ip) for b in bound]
        ret = [ctx.activate() for ctx in ctxz]

        log.debug("IoC '%s' resolved to '%s'", what, ret)
        return ret
コード例 #2
0
ファイル: container.py プロジェクト: mikhtonyuk/pyhk2
    def get(self, what, default=internal.raiseOnMissing):
        ret = default
        try:
            log.debug("Resolving '%s'", what)

            ip = inject_param(what)
            bound = self._binds.get(what)

            ctx = InjectionContext(self._binds, bound, ip)
            ret = ctx.activate()
        except InjectionError:
            if default == internal.raiseOnMissing:
                raise

        log.debug("IoC '%s' resolved to '%s'", what, ret)
        return ret
コード例 #3
0
ファイル: container.py プロジェクト: mikhtonyuk/pyhk2
 def inject(self, into):
     log.debug("Injecting dependencies into '%s'", into)
     ip = inject_param(into.__class__)
     ctx = InjectionContext(self._binds, InstanceBinding(into, NoScope), ip)
     ctx.inject(into)