Who handles dependency Injection in a class library?
Suppose there is a class library
TestService
TestService
which requires some dependencies. Whose responsibility would it be to handle it?
1. Let caller handle DI. This means caller will need to know about the underlying classes in the class library to be able to come up with the dependencies and use it. Seems a bit cumbersome? Like new TestService(dep1, dep2...), where deps could be interfaces defined in the class library 2. Providing default implementation in the class library ( maybe in constructor? ), so if dependencies are not passed in when creating the service, we create default concrete classes within the class library constructor and use them instead.
// make parameters optional, and create actual deps inside the constructor TestService(null, null)