Refactored code
This commit is contained in:
		
							
								
								
									
										26
									
								
								src_old/sh_edraft/service/providing/base/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								src_old/sh_edraft/service/providing/base/__init__.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,26 @@ | ||||
| # -*- coding: utf-8 -*- | ||||
|  | ||||
| """ | ||||
| sh_edraft.service.providing.base  | ||||
| ~~~~~~~~~~~~~~~~~~~ | ||||
|  | ||||
|  | ||||
|  | ||||
| :copyright: (c) 2020 sh-edraft.de | ||||
| :license: MIT, see LICENSE for more details. | ||||
|  | ||||
| """ | ||||
|  | ||||
| __title__ = 'sh_edraft.service.providing.base' | ||||
| __author__ = 'Sven Heidemann' | ||||
| __license__ = 'MIT' | ||||
| __copyright__ = 'Copyright (c) 2020 sh-edraft.de' | ||||
| __version__ = '2020.12.9' | ||||
|  | ||||
| from collections import namedtuple | ||||
|  | ||||
| # imports: | ||||
| from .service_provider_base import ServiceProviderBase | ||||
|  | ||||
| VersionInfo = namedtuple('VersionInfo', 'major minor micro') | ||||
| version_info = VersionInfo(major=2020, minor=12, micro=9) | ||||
| @@ -0,0 +1,33 @@ | ||||
| from abc import abstractmethod, ABC | ||||
| from collections import Callable | ||||
| from typing import Type | ||||
|  | ||||
| from sh_edraft.database.context.base.database_context_base import DatabaseContextBase | ||||
| from sh_edraft.service.base.service_base import ServiceBase | ||||
|  | ||||
|  | ||||
| class ServiceProviderBase(ABC): | ||||
|  | ||||
|     @abstractmethod | ||||
|     def __init__(self): pass | ||||
|  | ||||
|     @abstractmethod | ||||
|     def add_db_context(self, db_context: Type[DatabaseContextBase]): pass | ||||
|  | ||||
|     @abstractmethod | ||||
|     def get_db_context(self) -> Callable[DatabaseContextBase]: pass | ||||
|  | ||||
|     @abstractmethod | ||||
|     def add_transient(self, service_type: Type[ServiceBase], service: Type[ServiceBase]): pass | ||||
|  | ||||
|     @abstractmethod | ||||
|     def add_scoped(self, service_type: Type[ServiceBase], service: Type[ServiceBase]): pass | ||||
|  | ||||
|     @abstractmethod | ||||
|     def add_singleton(self, service_type: Type[ServiceBase], service: Callable[ServiceBase]): pass | ||||
|  | ||||
|     @abstractmethod | ||||
|     def get_service(self, instance_type: Type[ServiceBase]) -> Callable[ServiceBase]: pass | ||||
|  | ||||
|     @abstractmethod | ||||
|     def remove_service(self, instance_type: type): pass | ||||
		Reference in New Issue
	
	Block a user