ninject-2

Intercept Ninject instance activation?

这一生的挚爱 提交于 2019-12-23 17:37:17
问题 I'm trying to put an example together of using Caliburn Micro on WP7 with Ninject. Everything was pretty straight forward. However, I'm stuck on how to go about firing an event once an instance is Activated by Ninject. Here is the ActivateInstance method in Caliburn Micro's SimpleContainer, the IoC container that comes with CM for the phone. protected virtual object ActivateInstance(Type type, object[] args) { var instance = args.Length > 0 ? Activator.CreateInstance(type, args) : Activator

ASP.NET MVC 2, Ninject 2.2 and no parameterless constructor defined for this object

风格不统一 提交于 2019-12-23 10:29:32
问题 So I've been spending some time with ASP.NET MVC 2 (currently stuck with using Visual Studio 2008) and have now moved onto using Ninject 2.2 and its MVC integration. I've downloaded Ninject 2.2 and Ninject.Web.Mvc from the following locations: https://github.com/downloads/ninject/ninject/Ninject-2.2.0.0-release-net-3.5.zip https://github.com/downloads/ninject/ninject.web.mvc/Ninject.Web.Mvc2-2.2.0.0-release-net-3.5.zip And referenced them in my MVC 2 project. My Global.asax.cs file looks like

ASP.NET MVC 2, Ninject 2.2 and no parameterless constructor defined for this object

吃可爱长大的小学妹 提交于 2019-12-23 10:28:46
问题 So I've been spending some time with ASP.NET MVC 2 (currently stuck with using Visual Studio 2008) and have now moved onto using Ninject 2.2 and its MVC integration. I've downloaded Ninject 2.2 and Ninject.Web.Mvc from the following locations: https://github.com/downloads/ninject/ninject/Ninject-2.2.0.0-release-net-3.5.zip https://github.com/downloads/ninject/ninject.web.mvc/Ninject.Web.Mvc2-2.2.0.0-release-net-3.5.zip And referenced them in my MVC 2 project. My Global.asax.cs file looks like

Post-initialization object creation with ninject

人盡茶涼 提交于 2019-12-22 07:19:02
问题 I'm new to Ninject (and DI in general). I understand how the kernel loads modules, and the code I've written thus far tends to have a single line: myKernel.Get<MyApp>() which constructs everything I need from the bindings in my module. If there's a requirement for new instances post initialization, these are taken care of by factories that I bind for initialization. Up to now, the factories have been free of any ninject dependencies, simply newing up objects on demand. Now I have reached a

Ninject.MockingKernel.Moq security exception

天大地大妈咪最大 提交于 2019-12-22 00:34:10
问题 I am using Ninject for my IoC container and I'm trying to write some unit tests. I found the Ninject Mocking Kernel so I thought I'd give it a go but I can't get the simplest test to pass. I am missing something and need a little help. Moq.4.0.10827.Final Ninject-2.2.0.0-release-net-4.0 Ninject.MockingKernel-2.2.0.0-release-net-4.0 My unit test... [TestMethod] public void Constructor_CanInitialize() { var kernel = new MoqMockingKernel(); var mock = kernel.Get<IDataRepository>(); <--Error here

Ninject.MVC3, Pass DependencyResolver to service-layer?

懵懂的女人 提交于 2019-12-21 03:56:41
问题 In a MVC3-application with Ninject.MVC 2.2.0.3 (after merge), instead of injecting repostories directly into controllers I'm trying to make a service-layer that contain the businesslogic and inject the repostories there. I pass the ninject-DependencyResolver to the service-layer as a dynamic object (since I don't want to reference mvc nor ninject there). Then I call GetService on it to get repositories with the bindings and lifetimes I specify in NinjectHttpApplicationModule. EDIT: In short,

ASP.Net MVC 3, Ninject and Quartz.Net - How to?

旧街凉风 提交于 2019-12-20 08:49:52
问题 I am now using Ninject 2.2.1.4, with my MVC3, i'm success to config Ninject run with it, but i don't know how to make Ninject run with Quartz.Net in my MVC3 Can anyone help? 回答1: Create a JobFactory that uses Ninject public class NinjectJobFactory : IJobFactory { private readonly Func<Type, IJob> jobFactory; public NinjectJobFactory (Func<Type, IJob> jobFactory) { this.jobFactory = jobFactory; } public IJob NewJob(TriggerFiredBundle bundle) { return this.jobFactory(bundle.JobDetail.JobType);

Dependency Injection with Custom Membership Provider

坚强是说给别人听的谎言 提交于 2019-12-17 16:08:02
问题 I have an ASP.NET MVC web application that implements a custom membership provider. The custom membership provider takes a UserRepository to its constructor that provides an interface between the membership provider and NHibernate. The UserRepository is provided by the Ninject IoC container. Obviously, however, this doesn't work when the provider is instantiated by .NET: the parameterless constructor does not have a UserRepository and cannot create one (the UserRepository requires an

Binding singleton to multiple services in Ninject

╄→尐↘猪︶ㄣ 提交于 2019-12-17 11:53:08
问题 I have a problem which seems very similar to the one described in http://markmail.org/message/6rlrzkgyx3pspmnf which is about the singleton actually creating more than a single instance if you're accessing it using different service types. I'm using the latest release of Ninject 2 for Compact Framework and the exact issue I'm having is that if I bind the same provider method to: Func<Service> serviceCreator = () => new Service(false); kernel.Bind<IService>().ToMethod(serviceCreator)

Binding singleton to multiple services in Ninject

岁酱吖の 提交于 2019-12-17 11:53:07
问题 I have a problem which seems very similar to the one described in http://markmail.org/message/6rlrzkgyx3pspmnf which is about the singleton actually creating more than a single instance if you're accessing it using different service types. I'm using the latest release of Ninject 2 for Compact Framework and the exact issue I'm having is that if I bind the same provider method to: Func<Service> serviceCreator = () => new Service(false); kernel.Bind<IService>().ToMethod(serviceCreator)