cpl@2022.6.3 - Verbesserung der Parameter #67
@ -10,7 +10,6 @@ from cpl_core.dependency_injection.service_lifetime_enum import ServiceLifetimeE
|
||||
from cpl_core.dependency_injection.service_provider import ServiceProvider
|
||||
from cpl_core.logging.logger_service import Logger
|
||||
from cpl_core.logging.logger_abc import LoggerABC
|
||||
from cpl_core.utils.credential_manager import CredentialManager
|
||||
|
||||
|
||||
class ServiceCollection(ServiceCollectionABC):
|
||||
@ -59,12 +58,15 @@ class ServiceCollection(ServiceCollectionABC):
|
||||
|
||||
self._add_descriptor(impl, ServiceLifetimeEnum.singleton)
|
||||
|
||||
return self
|
||||
|
||||
def add_scoped(self, service_type: Type, service: Callable = None):
|
||||
if service is not None:
|
||||
self._add_descriptor(service, ServiceLifetimeEnum.scoped)
|
||||
else:
|
||||
self._add_descriptor(service_type, ServiceLifetimeEnum.scoped)
|
||||
|
||||
return self
|
||||
|
||||
def add_transient(self, service_type: type, service: type = None):
|
||||
if service is not None:
|
||||
@ -72,5 +74,7 @@ class ServiceCollection(ServiceCollectionABC):
|
||||
else:
|
||||
self._add_descriptor(service_type, ServiceLifetimeEnum.transient)
|
||||
|
||||
return self
|
||||
|
||||
def build_service_provider(self) -> ServiceProviderABC:
|
||||
return ServiceProvider(self._service_descriptors, self._configuration, self._database_context)
|
||||
|
@ -31,7 +31,7 @@ class ServiceCollectionABC(ABC):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def add_transient(self, service_type: Type, service: Callable = None):
|
||||
def add_transient(self, service_type: Type, service: Callable = None) -> 'ServiceCollectionABC':
|
||||
r"""Adds a service with transient lifetime
|
||||
|
||||
Parameter
|
||||
@ -40,11 +40,15 @@ class ServiceCollectionABC(ABC):
|
||||
Type of the service
|
||||
service: :class:`Callable`
|
||||
Object of the service
|
||||
|
||||
Returns
|
||||
------
|
||||
self: :class:`cpl_core.dependency_injection.service_collection_abc.ServiceCollectionABC
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def add_scoped(self, service_type: Type, service: Callable = None):
|
||||
def add_scoped(self, service_type: Type, service: Callable = None) -> 'ServiceCollectionABC':
|
||||
r"""Adds a service with scoped lifetime
|
||||
|
||||
Parameter
|
||||
@ -53,11 +57,15 @@ class ServiceCollectionABC(ABC):
|
||||
Type of the service
|
||||
service: :class:`Callable`
|
||||
Object of the service
|
||||
|
||||
Returns
|
||||
------
|
||||
self: :class:`cpl_core.dependency_injection.service_collection_abc.ServiceCollectionABC
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def add_singleton(self, service_type: Type, service: Callable = None):
|
||||
def add_singleton(self, service_type: Type, service: Callable = None) -> 'ServiceCollectionABC':
|
||||
r"""Adds a service with singleton lifetime
|
||||
|
||||
Parameter
|
||||
@ -66,6 +74,10 @@ class ServiceCollectionABC(ABC):
|
||||
Type of the service
|
||||
service: :class:`Callable`
|
||||
Object of the service
|
||||
|
||||
Returns
|
||||
------
|
||||
self: :class:`cpl_core.dependency_injection.service_collection_abc.ServiceCollectionABC
|
||||
"""
|
||||
pass
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user