Fixed static di injection

This commit is contained in:
Sven Heidemann 2023-01-07 15:00:38 +01:00
parent 48d0daabf5
commit 6389a940bc
2 changed files with 6 additions and 4 deletions

View File

@ -4,7 +4,7 @@
"Version": {
"Major": "2022",
"Minor": "12",
"Micro": "1"
"Micro": "1.post1"
},
"Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de",

View File

@ -13,14 +13,16 @@ class ServiceProviderABC(ABC):
_provider: Optional['ServiceProviderABC'] = None
@abstractmethod
def __init__(self): pass
def __init__(self):
pass
@classmethod
def set_global_provider(cls, provider: 'ServiceProviderABC'):
cls._provider = provider
@abstractmethod
def build_by_signature(self, sig: Signature) -> list[T]: pass
def build_by_signature(self, sig: Signature) -> list[T]:
pass
@abstractmethod
def build_service(self, service_type: type) -> object:
@ -108,7 +110,7 @@ class ServiceProviderABC(ABC):
if cls._provider is None:
raise Exception(f'{cls.__name__} not build!')
injection = cls._provider.build_by_signature(signature(f))
injection = [x for x in cls._provider.build_by_signature(signature(f)) if x is not None]
return f(*injection, *args, **kwargs)
return inner