Options for wiring dependencies with NInject

前端 未结 4 1957
悲哀的现实
悲哀的现实 2020-12-11 06:31

With NInject (preferably 2.0), what options do we have wrt wiring up our object dependencies in a web application?

Can they be defined in an XML configuration file?

4条回答
  •  [愿得一人]
    2020-12-11 06:39

    What are you looking to achieve? What sort of stuff are you looking to configure? Dynamically selecting a Strategy ? Passing in Port numbers? You could offer a lot more information as to what you're thinking in order to get a better answer [that you can acccept :P].

    You need to split the concerns of:

    1. known object wiring (DI)
    2. configuration - generally you'll want to split those into small focused subsets e.g. Strongly Typed config elements vs having a global pool of settings in a big pile mishmashed together a la appSettings
    3. plugins / unknown object wiring (MEF?)

    In the first pool, doing it in Code is just the right way and I cant think of any advantage XML would give, esp. in the context of strong names etc.

提交回复
热议问题