How easy it is to determine if Ninject can resolve a class

I am introducing Ninject into a big mess of an existing project. I want to write a diagnostic test to make sure that all Ninject classes will eventually be created, Ninject can actually be resolved ... without actually creating any of them.

The reason I want to avoid the actual construct is because many of these classes tend to run database operations in their constructors (sigh, yes, I know). Otherwise, I would just run them through Get<T>with try / catch

+5
source share
2 answers

CanResolve IResolutionRoot (.. Kernel, using ). CreateRequest, . , .

+4

, , , , , , Ninject get() .

Ninject 3.0.2 CanResolve, :

kernel.CanResolve<T>()

3.0.2 nuget, (Ninject.3.0.2-unstable-9037), , .

+1

All Articles