How to translate this statement to Ninject

Dec 11, 2014 at 3:04 PM
Edited Dec 11, 2014 at 3:22 PM
Hi there,

Can anyone help me to translate the following state to Ninject please?
                .RegisterType<IRepositoryProvider, RepositoryProvider>(
                    new PerRequestLifetimeManager(), 
                    new InjectionConstructor(new object[]{new RepositoryFactories()})
                    )
I currently have the code like this,
kernel.Bind<IRepositoryProvider>().To<RepositoryProvider>().InSingletonScope();
But I don't know how to translate the
 new InjectionConstructor(new object[]{new RepositoryFactories()})
Can anyone help?

Thank you so much!

I have tried
kernel.Bind<IRepositoryProvider>().To<RepositoryProvider>().InSingletonScope().WithConstructorArgument(new RepositoryFactories());
Is it correct?
Dec 11, 2014 at 6:51 PM
I have no experience with Ninject but I noticed a difference with the statement you attempted. You didn't have the "new object[]" portion. Have you tried,

kernel.Bind<IRepositoryProvider>().To<RepositoryProvider>().InSingletonScope().WithConstructorArgument(new object[] { new RepositoryFactories() } );
Dec 12, 2014 at 4:43 PM
Thank you for your suggestion.
Dec 15, 2014 at 5:34 PM
kernel.Bind<IRepositoryProvider>().To<RepositoryProvider>().InRequestScope().WithConstructorArgument<RepositoryFactories>(new RepositoryFactories());
new PerRequestLifetimeManager() translates into InRequestScope(), not InSingletonScope().

Please, notice that if you ever use more than a context, InRequestScope() or InSingletonScope() won't work. In that case you'll need neither since you won't want to share the repositories.
Marked as answer by lelong37 on 12/18/2014 at 3:25 PM
Dec 15, 2014 at 6:19 PM
Thank you so much for your help!