Is there a way to combine a call to FromAssembliesMatching to set up most interfaces automatically and some explicit bindings? I have the following code that should set all ISomething to Something automatically, and then set up a specific constructor for the IUnitOfWork interface where the concrete implementation accepts two bools as arguments:
kernel.Bind(x => x.FromAssembliesMatching("*.dll").SelectAllClasses()
.InNamespaces("MyNamespace").BindDefaultInterface());
kernel.Bind<IUnitOfWork>().ToConstructor(x => new UnitOfWork(true, false));
However, when I try to call TryGet like this I get a null back:
kernel.TryGet<MyNamespace.IUnitOfWork>()
It works fine when I switch the order around and call Excluding for the UnitOfWork implementation explicitly on the second call:
kernel.Bind<IUnitOfWork>().ToConstructor(x => new UnitOfWork(true, false));
kernel.Bind(x => x.FromAssembliesMatching("*.dll").SelectAllClasses()
.InNamespaces("MyNamespace").Excluding(typeof(UnitOfWork))
.BindDefaultInterface());
Reversing the order, or leaving out the call to Excluding results in null again when I try to resolve an instance of an IUnitOfWork.
What's the proper way to combine automatic matching with explicit configuration? I am using Ninject 3.2.0.0 and Ninject.Extensions.Conventions 3.2.0.0.