-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
40 lines (33 loc) · 924 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import os
import sys
from injector import Injector
from container.service_di_container import ServiceDiContainer
from domain.car import Car
def main():
config = {
'services': {
'DieselEngine': {
'class': 'domain.diesel_engine.DieselEngine'
},
'GasolineEngine': {
'class': 'domain.gasoline_engine.GasolineEngine'
},
'ElectroEngine': {
'class': 'domain.electro_engine.ElectroEngine'
}
}
}
# DieselEngine
injector = Injector(
[ServiceDiContainer(config['services']['DieselEngine'])])
car = injector.get(Car)
rtn = car.run()
print(rtn)
# ElectroEngine
injector = Injector(
[ServiceDiContainer(config['services']['ElectroEngine'])])
car = injector.get(Car)
rtn = car.run()
print(rtn)
if __name__ == '__main__':
main()