Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. COWont work - the problem is that Ninject's `IInitialize` interface is called for every activation (i.e., creation as part of a `Bind` stream). Your example boils down to the same thing as the question and hence will end up initializing twice too.
      singulars
    2. COI would say in this way, implementing IInitialize is totally unnecessary, and is a bad practice - if some day you have to switch to another container, your code needs to be changed, you have to remember it was initialized by container, and if you forget that and just removed the interface to make it compile, you will get runtime problem. On the other hand, if a "new" can handle it, why make it so complicated, anyway, container is to serve us to make code simpler, not harder, and the Moudle's purpose is to construct object, I don't mind "new" it myself.
      singulars
    3. COI agree with your general sentiments (constructor injection, no container-specifics leaking into business logic etc.). My key point and the reason for the -1 is that a) your code is the same as the code in the question that the OP said didnt work b) it thus doesnt answer or solve the question. The purpose of IInitializable is to facilitate two phase construction and can be useful if you have to rsort to prop injection (e.g. if your environment rules out constructor injection). But that's all a digression that has little to do with the question.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload