Making Unity to try all constructors

Dec 2, 2010 at 2:20 PM
Edited Dec 2, 2010 at 2:20 PM
I don't want Unity to only try the constructor with most parameters. 
I want it to continue trying until it finds a suitable constructor. 
If Unity doesn't provide this behavior by default, is it possible to create an extension or something to be able to do this?


foreach (var constructor in concrete.GetConstructorsOrderByParameterCount())

Feb 7, 2011 at 11:11 PM
Edited Feb 7, 2011 at 11:13 PM

This is not the way Unity resolution process was designed to work.

With regard to whether it's possible to implement as a custom extension, you can but that would require changing dynamic codegen, which is not a trivial task.

Moreover, we would recommend this behavior since it would make the resolution process unpredictable.