ninject-2

Context variables in Ninject 2

I found this article on Context Variables in an earlier version of Ninject. My question is two-fold. First, how can I get this behavior with Ninject 2? Secondly, do context variables carry through down the request chain? For example, let's say I wanted to replace these calls: var a = new A(new B(new C()))); var specialA = new A(new B(n...

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 ...