Pregunta de entrevista de CID

How would you implement Dependency Injection?

Respuesta de la entrevista

Anónimo

27 de nov de 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).