Making Unity to try all constructors

Dec 2, 2010 at 3:20 PM
Edited Dec 2, 2010 at 3: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 8, 2011 at 12:11 AM
Edited Feb 8, 2011 at 12:13 AM

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.