KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a MVC 3 solution configured with Ninject using a repository pattern. Some of my bindings include: kernel.Bind<IDatabaseFactory>().To<DatabaseFactory>().InRequestScope(); kernel.Bind<IUnitOfWork>().To<UnitOfWork>().InRequestScope(); kernel.Bind<IMyRepository>().To<MyRepository>().InRequestScope(); kernel.Bind<IMyService>().To<MyService>().InRequestScope(); kernel.Bind<ILogging>().To<Logging>().InSingletonScope(); I also added a console application to my solution and I want to leverage the same repository and services. My Ninject configuration for the console application looks like: kernel.Bind<IDatabaseFactory>().To<DatabaseFactory>().InSingletonScope(); kernel.Bind<IUnitOfWork>().To<UnitOfWork>().InSingletonScope(); kernel.Bind<IMyRepository>().To<MyRepository>().InSingletonScope(); kernel.Bind<IMyService>().To<MyService>().InSingletonScope(); kernel.Bind<ILogging>().To<Logging>().InSingletonScope(); My console code looks like: static void Main(string[] args) { IKernel kernel = new StandardKernel(new IoCMapper()); var service = kernel.Get<IMyService>(); var logger = kernel.Get<ILogging>(); ... do some processing here } This works just fine but I want t be sure that I am configuring Ninject correctly for a console application. Is it correct to use InSingletonScope() for all my bindings in my console application? Should I be configuring it differently?
Tags (comma-separated)
Save Edits
Cancel