Tuesday 15 June 2010

c# - ninject binding rule precedence for overlapping rules? -


When I have two Ninject binding rules that overlap in the field, one is more specific than the other They are:

  • Will Vinod automatically select the most specific binding rule while constructing the object?
  • Do I have to keep more general rules in order

    For example, consider the two rules given below:

      // More specific (constrained) rules which are constrained to / / a special class bind & lt; ISome interface & gt; (). & Lt; SomeOtherClass & gt; () .WhenInjectedInto (typeof (ParticularClassBeingConstructed)); // Bind more general rules for any ISomeInterface match & lt; ISomeInterface & gt; () & Lt; SomeClass & gt; ();  

    The first binding will only apply when ParticularClassBeingConstructed and the other The rule will also be used when any other type requires ISomeInterface (like a normal binding if no more specific one is present).

    'I do not make any difference.'

No comments:

Post a Comment