ninject/ninject — pull request #117 by BrunoJuchli (2014-01-15 16:38:00+00:00)
Title: Add TryGet for "null object" pattern.

Hi
Can we have a TryGet which fails when a binding exists but could not be instantiated?

I've created a pull request. I've named the method "TryGetAndThrowOnInvalidBinding" for backwards-compatibility reasons.

However there is one issue remaining (=unit test failing):
In the case that there are multiple valid bindings i would like to throw an exception rather than returning null.
This could be achieved by setting the IsUnique parameter to false.
However this would then break support for conditional bindings - in case there is a "default" unconditional binding (the binding with met conditions should be returned).

Any ideas?