Using Generic Types while binding with Ninject - is it possible?

Can't test it right now but this should work: Bind(typeof (Dao)). To(typeof(Dao)) Using an interface, a probably better idea going forward: Bind(typeof (IDao)). To(typeof(Dao)).

Can't test it right now but this should work: Bind(typeof (Dao)). To(typeof(Dao)); Using an interface, a probably better idea going forward: Bind(typeof (IDao)). To(typeof(Dao)).

Why don't do this in load : Bind>.ToSelf().

I will explain it in my next answer ;) – Stefan Aug 26 at 12:20.

You should be codding against interface as it will make your code alot more testable. Have a look at this more info on Ninject binding Ninject Binding ok in your case you need to do this (not tested). As long as you tell Inject the concrete implmentations it will take care of the injection at the right places for you depending that you have the right inject attributes in place in your code.

Class MyBindings : NinjectModule { public override void Load() { Bind(). To; Bind().To(); Bind().To(); } }.

Yes, you are right. But that's where I came from :( First my code looked like this: Bind>(). To>(); But as I saw, that this won't work, I started debugging my code.So - finally I got that what I posted at first.

Whatever I did, the error is still the same. – Stefan Aug 26 at 12:21 I tried your solution too - but even that does not work. If I try so, I will get a compiler error: "Fehler 1 Using the generic type 'SessionPerPresenter.Data.

IDao' requires '1' type arguments D:\...blah...\SessionPerPresenter\Program. Cs 67 18 SessionPerPresenter " – Stefan Aug 26 at 12:36 the only way we can help you is if you post some code. Will that be possible so I can replicate it on my site.

– Bobby Aug 26 at 12:41 Of course it is possible - I will post it in a few minutes :) – Stefan Aug 26 at 12:59 GOT IT! Thanks guys - you showed me the right way, but I was almost blind :) Here is what I found out: My DAO-class has an constructor with one parameter public Dao(ISessionFactory sessionFactory) As I am new to Ninject, I forgot that and did not bind that 'sessionfactory'. After binding it, everything works fine.

Thanks a lot for your help :) Stefan – Stefan Aug 26 at 13:28.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions