Simple Dependency Resolver

前端 未结 2 1496
再見小時候
再見小時候 2020-12-04 16:07

How do you create simple Dependency Resolver, with out using any built in or library such as Autofac, Ninject, etc.

This was my interview question.

I wrote t

2条回答
  •  被撕碎了的回忆
    2020-12-04 16:37

    It's already a few years old, but Ayende once wrote a blog post about this:
    Building an IoC container in 15 lines of code

    But this is only the very simplest possible implementation.
    Ayende himself stated in his next post that the existing IoC containers can do much more stuff than just returning class instances - and this is where it gets complicated.
    As "Trust me - I'm a Doctor" already said in his comment: implementing a complete IoC container is everything but trivial.

提交回复
热议问题