ninject

Ninject inject add an element to collection when I create the collection

I'm using MVVM light and have set up the binding as following: class TestModule:NinjectModule { public override void Load() { Bind<ICollection<Element>>().To<Collection<Element>>(); Bind<Element>().ToSelf(); } } When I try to get a ICollection I get a collection with ONE element. I expect an exmpty collecti...

Use factory method in Ninject that I can't add attribute to.

I try to use Ninject to inject a XmlReader. The problem is that it is created by a factory method insted of a constructor. And I can't add a [Inject] to code in the .NET Framework. Now I use following binding to create the XmlReader: Bind<IXmlReader>() .ToMethod( x => XmlReader.Create( (string...

How to use Ninject Conventions extension without referencing Assembly (or Types within it)

Sorry in advance for the long question, it's long because I've been digging at this all day. The general problem: I have an ASP.Net MVC2 application with the following projects: MyApp.Web, MyApp.Services, MyApp.Data. We code to interfaces and utilize Ninject 2 for DI/IoC. However, I'm getting awfully tired of typing (and forgetting ...

Injecting a property when creating a Object

I have a LoggedTextWriter that I'd like to inject in to the Log property of the LinqToSql DataContext class. My custom LoggedTextWriter has a constructor that takes ICustomWriter, but I don't know how to inject it in to the Log property. Bind<DataContext>() .ToSelf() .InTransientScope() ....

Ninject to StructureMap

I am looking to convert following code to StructureMap: private Mock<MembershipProvider> MockMembership = new Mock<MembershipProvider>(); private StandardKernel GetIoCKernel() { var modules = new IModule[] { new InlineModule( new Action<InlineModule>[] { m => m.Bind<MembershipPro...

Ninject, how to inject an object living in the session into my business class?

I have a profile object in session with profile information for the currently logged in user. I wand to be able to inject it into my business classes so I can do validation etc in them without having to pass it in the parameter list in every method. I have tried something like this in my ninject module: Profile profile = HttpContext.C...

Use Mvc 2 with ninject 2 and NHibernate - Get SessionFactory

Hey I'm trying to combine Mvc2 with Ninject and NHibernate, and found a guide here: http://damianm.com/tech/nhibernate-mvc-and-ninject/ The problem is that he use Ninject 1. So i have to convert it, and I'm almost succesfull, but i still got one problem: Im not sure how to convert the "context.Kernel.Get" here: protected override ISe...