Cool. The WhenInjectedInto syntax looks good for me. Thanks!
In spring dependency injection can work in a more push-like model, so
you can say "inject this (singleton) instance with this object, and
this other instance with another object". This way, specific strings
and lists and whatnot can be injected too. A pull-like model like
ninject is probably possible too. Philosophically, I can agree with
both models. In most cases you just need 'an' instance of the
interface. In specific cases however, you might want a specific
instance. Dependency injection is still the way to go, because the
class itself shouldn't need to care about what instance. Also,
ninject's module system gives a lot of flexibility too.
Thanks and best regards,
Matthijs
On 25 nov, 02:44, Sean Chambers <
schamber...@gmail.com> wrote:
> Hello,
>
> I've never used ninject in this manner, but I believe you can do this using
> the .Named() syntax:
>
> Bind<IProductReader>().To<ProductReader>().Named("ProductReader");
>
> then to retrieve:
>
> Kernel.Get<IUserRepository>( "ProductReader", null );
>
> this only works if you are using a service locator or the like to retrieve
> the instances.
>
> Another option is to use the .WhenInjectedInto if you want to restrict it:
>
> Bind<IProductReaderWriter>().To<ProductReaderWriter>().WhenInjectedInto<MyOtherService>();
>
> Ian and others can correct me if i'm wrong, but at first glance something
> along those lines would probably work.
>
> Sean
>
> On Tue, Nov 24, 2009 at 6:02 PM, Matthijs <
matthijs.wensv...@gmail.com>wrote:> Hello all,
> >
ninject+u...@googlegroups.com<
ninject%2Bunsu...@googlegroups.com>
> > .