Domanda di colloquio di CID

How would you implement Dependency Injection?

Risposta di colloquio

Anonimo

27 nov 2017

I would create a static class with a dictionary inside. Dictionary should consist of type and object itself. That would be singleton. For other objects it could be created through factory methods. So maybe it would make sense to also provide a method to register a type with factory action callback. However, I believe .NET has wonderful dependency injection frameworks (like Ninject or Autofac or the one provided by Microsoft in dotnet core).