Reputation: 23247
I have these 3 interfaces:
interface IA {}
interface IB {}
interface IC {}
Also, I've this other interface which inherits from IA
, IB
and IC
:
interface II : IA, IB, IC {}
Then, I've also created a class CC
inherits from II
:
class CC : II {}
I've created these bindings:
this.Bind<IA>().To<CC>().InSingletonScope();
this.Bind<IB>().To<CC>().InSingletonScope();
this.Bind<IC>().To<CC>().InSingletonScope();
this.Bind<II>().To<CC>().InSingletonScope();
I don't know if, each time I've to request for a whichever interface, NInject kernel is going to give the same singleton instance of CC
.
So, I mean:
IA ia = kernel.Get<IA>();
IB ib = kernel.Get<IB>();
ia
is the same instance that ib
?
How could I get this behavior?
Upvotes: 2
Views: 187
Reputation: 15413
As far as I know, this should work :
this.Bind<IA, IB, IC, II>().To<CC>().InSingletonScope();
The overload of Bind
takes up to four type parameters.
Upvotes: 4