I'm attempting to create a nancy bootstrapper for DryIoc (v2.0 preview). Generally most things seem simple, however DryIoc appears to not obviously support one of the things that Nancy relies on for its bootstrapping.
The inbuilt tinyioc container will, when faced with a type with two 'same length' constructors (i.e. same number of arguments, but they are of different types) resolve the one which it has a complete set of type registrations for.
When running my bootstrapper, in the RegisterTypes
method an exception is thrown:
Additional information: Unspecified how to select single constructor for implementation type Nancy.ViewEngines.FileSystemViewLocationProvider with 2 public constructors.
It is probably quite simple what I need to do within my DryIoc implementation, but I haven't figured it out yet. If anyone has any suggestions, please reply!
My current nancy bootstrapper implementation: Bitbucket Snippet
By default DryIoc expects single public constructor to inject dependencies. But it could be customized per Container using Rules. Given your case you can customize constructor selection as following:
var container = new Container(rules =>
rules.With(FactoryMethod.ConstructorWithResolvableArguments));
But if setting this behavior per Container may be overkill, you may set it for specific registration:
container.Register<IService, SomeService>(made: Made.Of(FactoryMethod.ConstructorWithResolvableArguments));
More complete usage examples could be found here.
Update:
The Nancy integration package is out: Nancy.Bootstrappers.DryIoc