Files
cpl/tests/custom/di/src/di/application.py
edraft b97bc0a3ed
All checks were successful
Build on push / prepare (push) Successful in 8s
Build on push / query (push) Successful in 17s
Build on push / core (push) Successful in 26s
Build on push / translation (push) Successful in 15s
Build on push / mail (push) Successful in 17s
Restructuring
2025-09-16 08:48:07 +02:00

45 lines
1.5 KiB
Python

from cpl.application import ApplicationABC
from cpl.core.configuration import ConfigurationABC
from cpl.core.console.console import Console
from cpl.dependency import ServiceProviderABC
from cpl.dependency.scope import Scope
from di.static_test import StaticTest
from di.test_abc import TestABC
from di.test_service import TestService
from di.di_tester_service import DITesterService
from di.tester import Tester
class Application(ApplicationABC):
def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):
ApplicationABC.__init__(self, config, services)
def _part_of_scoped(self):
ts: TestService = self._services.get_service(TestService)
ts.run()
def configure(self):
pass
def main(self):
with self._services.create_scope() as scope:
Console.write_line("Scope1")
ts: TestService = scope.service_provider.get_service(TestService)
ts.run()
dit: DITesterService = scope.service_provider.get_service(DITesterService)
dit.run()
with self._services.create_scope() as scope:
Console.write_line("Scope2")
ts: TestService = scope.service_provider.get_service(TestService)
ts.run()
dit: DITesterService = scope.service_provider.get_service(DITesterService)
dit.run()
Console.write_line("Global")
self._part_of_scoped()
StaticTest.test()
self._services.get_service(Tester)
Console.write_line(self._services.get_services(list[TestABC]))