Fixed static di injection
This commit is contained in:
parent
48d0daabf5
commit
6389a940bc
@ -4,7 +4,7 @@
|
||||
"Version": {
|
||||
"Major": "2022",
|
||||
"Minor": "12",
|
||||
"Micro": "1"
|
||||
"Micro": "1.post1"
|
||||
},
|
||||
"Author": "Sven Heidemann",
|
||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user