I am using Ninject 1.0 and want to be able to add lazy initialization delegates to constructors. So, given the general definition of a delegate:
public delegate T LazyGet<T>();
I would just like to bind this to IKernel.Get () so that I can pass a lazy getter to constructors, for example.
public class Foo { readonly LazyGet<Bar> getBar; public Foo( LazyGet<Bar> getBar ) { this.getBar = getBar; } }
However, I cannot just call Bind<LazyGet<T>>() because it is an open generic type. I need this to be an open generic one, so I donβt need to bind all the different lazy ones to get explicit types. In the above example, it should be possible to dynamically create a shared delegate that calls IKernel.Get<T>() .
How can this be achieved with Ninject 1.0?
source share