views:

222

answers:

1

Hi guys

Just wondering how Castle Windsor determines which constructor to resolve when there are multiple constructors present.

Cheers Anthony

+5  A: 

All available constructors are modeled as candidates and basically a contest is run among them.

Each parameter in a constructor represents a dependency that can be either satisfied or not. For each constructor candidate, all dependencies are analyzed.

If a dependency can be satisfied, that's two points for the candidate. If it can't be satisfied, two points are subtracted from the candidate.

The constructor candidate with the most points wins and is chosen to instantiate the component.

The code for this algorithm is here.

Mauricio Scheffer
Thanks for the information...
vdh_ant
Thanks for the info Mauricio. I'm having "problems" with Windsor in a S#arpArch related project and that helps a lot!
WillCodeForCoffee