ninject-extensions

Ninject Conventions with Ninject Factory Extension To Bind Multiple Types To One Interface

回眸只為那壹抹淺笑 提交于 2019-12-02 04:55:00
I'm trying to expand on the scenario asked in the SO question titled Ninject Factory Extension Bind Multiple Concrete Types To One Interface by using Ninject Conventions for convention-based binding of the ICar implementations. I'm working off the accepted answer authored by Akim and his Gist outlining the full example. The difference is that I've replaced the explicit ICar bindings with convention-based bindings (or an attempt at it, at least ;) public class CarModule : NinjectModule { public override void Load() { Bind<ICarFactory>() .ToFactory(() => new

Ninject 3 InRequestScope not returning the same instance for the same request

青春壹個敷衍的年華 提交于 2019-12-01 16:44:04
Recently, I upgraded one of my MVC3 projects from Ninject 2 to Ninject 3. After a couple of minutes trying to find why InRequestScope was not anymore available, I found that this is now an extension of Ninject.Web.Common. Now, when I try to run the application, Ninject works like if all types binded with a scope InRequest would be InTransientScope; a new instance was created each time. In my class that inherits from NinjectModule, I have a simple bind like that: Bind<ViewModel.Activity>().ToSelf().InRequestScope(); In my controller, I have 2 properties of the type ViewModel.Activity marked

Upgrading Ninject/Ninject WCF Extensions to the latest version 3.0.0.5

浪子不回头ぞ 提交于 2019-11-29 06:45:20
I am currently using Ninject (2.2.1.4) and Ninject.Extensions.Wcf (2.2.0.4) with my WCF service. I would like to upgrade to Ninject (3.0.0.15) and Ninject.Extensions.Wcf (3.0.0.5) and it doesn't look like I can use my current approach anymore. Can anyone point me to some samples or posts on how to get the latest version of Ninject working with a WCF project. My current approach: I wrote a module: public class NinjectDependencyResolver : NinjectModule { public override void Load() { // Declare bindings } } I added the Factory Attribute to my .svc file Factory="Ninject.Extensions.Wcf

Ninject-ing a dependency in Global.asax

拈花ヽ惹草 提交于 2019-11-29 04:15:32
问题 I'm starting a web application with MVC3 and Ninject. There is one dependency that I also need in the Global.asax file that needs to be a singleton. I thought it should be like this: public class MvcApplication : NinjectHttpApplication { IUserAuthentication _auth; public MvcApplication() { base.AuthenticateRequest += new EventHandler(MvcApplication_AuthenticateRequest); } protected override IKernel CreateKernel() { var _kernel = new StandardKernel(new SecurityModule()); _auth = _kernel.Get

Ninject Conditional Self bind to change scope (For Task-scheduler) not working properly?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-28 08:44:16
问题 Within MVC Web Application DbContext binding work properly with InRequestScope() kernel.Bind<DbContext>().ToSelf().InRequestScope(); kernel.Bind<IUnitOfWork<DbContext>>().To<UnitOfWork<DbContext>>(); But from a Task Scheduler call DbContext in InRequestScope() unable to update Db Table ( without any error ), until I change Binding to InSingletonScope() OR InThreadScope() Question: So is their any way change scope to InSingletonScope() / InThreadScope() for a Task Scheduler Call. ? // For Task