Complete the code to declare a dependency injection container.
container = [1]()The DIContainer is the standard class to create a dependency injection container.
Complete the code to register a service class in the container.
container.[1](MyService)The singleton method registers a service as a single shared instance.
Fix the error in the code to retrieve a service instance from the container.
service = container.[1](MyService)The resolve method is used to get the instance of a registered service.
Fill both blanks to define a service with constructor injection.
class MyController: def __init__(self, [1]): self.service = [2]
The constructor takes service as parameter and assigns it to self.service for use in the class.
Fill all three blanks to register and resolve a service with dependencies.
container.[1](MyRepository) container.[2](MyService, lambda: MyService([3]))
First, register the repository. Then, register singleton service with a factory lambda that calls container.resolve(MyRepository) to inject the dependency.