2022.12 #133
@ -93,7 +93,7 @@ class ServiceProvider(ServiceProviderABC):
|
|||||||
self._scope = scope
|
self._scope = scope
|
||||||
|
|
||||||
def create_scope(self) -> ScopeABC:
|
def create_scope(self) -> ScopeABC:
|
||||||
sb = ScopeBuilder(ServiceProvider(self._service_descriptors, self._configuration, self._database_context))
|
sb = ScopeBuilder(ServiceProvider(copy.deepcopy(self._service_descriptors), self._configuration, self._database_context))
|
||||||
return sb.build()
|
return sb.build()
|
||||||
|
|
||||||
def get_service(self, service_type: type) -> Optional[object]:
|
def get_service(self, service_type: type) -> Optional[object]:
|
||||||
|
@ -20,25 +20,22 @@ class Application(ApplicationABC):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def main(self):
|
def main(self):
|
||||||
|
with self._services.create_scope() as scope:
|
||||||
Console.write_line('Scope1')
|
Console.write_line('Scope1')
|
||||||
scope1: Scope = self._services.create_scope()
|
ts: TestService = scope.service_provider.get_service(TestService)
|
||||||
ts: TestService = scope1.service_provider.get_service(TestService)
|
|
||||||
ts.run()
|
ts.run()
|
||||||
dit: DITesterService = scope1.service_provider.get_service(DITesterService)
|
dit: DITesterService = scope.service_provider.get_service(DITesterService)
|
||||||
dit.run()
|
dit.run()
|
||||||
t = scope1
|
|
||||||
b = t.service_provider
|
|
||||||
scope1.dispose()
|
|
||||||
|
|
||||||
#Console.write_line('Disposed:')
|
#Console.write_line('Disposed:')
|
||||||
#ts1: TestService = scope1.service_provider.get_service(TestService)
|
#ts1: TestService = scope1.service_provider.get_service(TestService)
|
||||||
#ts1.run()
|
#ts1.run()
|
||||||
|
|
||||||
|
with self._services.create_scope() as scope:
|
||||||
Console.write_line('Scope2')
|
Console.write_line('Scope2')
|
||||||
scope2: Scope = self._services.create_scope()
|
ts: TestService = scope.service_provider.get_service(TestService)
|
||||||
ts: TestService = scope2.service_provider.get_service(TestService)
|
|
||||||
ts.run()
|
ts.run()
|
||||||
dit: DITesterService = scope2.service_provider.get_service(DITesterService)
|
dit: DITesterService = scope.service_provider.get_service(DITesterService)
|
||||||
dit.run()
|
dit.run()
|
||||||
|
|
||||||
Console.write_line('Global')
|
Console.write_line('Global')
|
||||||
|
@ -16,7 +16,10 @@
|
|||||||
"LicenseName": "",
|
"LicenseName": "",
|
||||||
"LicenseDescription": "",
|
"LicenseDescription": "",
|
||||||
"Dependencies": [
|
"Dependencies": [
|
||||||
"sh_cpl>=2021.10.0.post1"
|
"cpl-core==2022.12.0"
|
||||||
|
],
|
||||||
|
"DevDependencies": [
|
||||||
|
"cpl-cli==2022.12.0"
|
||||||
],
|
],
|
||||||
"PythonVersion": ">=3.9.2",
|
"PythonVersion": ">=3.9.2",
|
||||||
"PythonPath": {},
|
"PythonPath": {},
|
||||||
|
Loading…
Reference in New Issue
Block a user