ninject-3

Ninject 3 multiple bindings

旧时模样 提交于 2019-12-24 17:25:44
问题 My question is really a repeat of an old question posted here: Ninject 2.2 multiple bindings It seems someone was going to deal with this back in 2011. Does anyone know if there is some way to turn off such warnings in Ninject? Or some other workaround? EDIT In response to @BatteryBackupUnit, here is my exact problem: I have multiple libraries... and in my core library, I do something like this: Find all assemblies referenced by the host application (including the host) Find all types

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

霸气de小男生 提交于 2019-12-20 04:54:10
问题 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 {

Using default parameter values with Ninject 3.0

为君一笑 提交于 2019-12-18 19:27:32
问题 I have a class with a constructor having a parameter with a default value. With Ninject 2.2, it would honor the [Optional] attribute and work fine with no binding defined against a constructor declared like so: public EmployeeValidator([Optional] IValidator<PersonName> personNameValidator = null) Since upgrading to Ninject 3.0, construction of this object fails with a message stating that the provider returned null: Test method ValidatorIsolated.Tests.EmployeeValidatorTest

Disable implicit binding/injection of non explicitly bound classes in Ninject 2+

随声附和 提交于 2019-12-04 11:41:26
问题 If you request an unbound object from NInject, then the default behaviour is (if a suitable constructor is available) appears to be to create an instance of the appropriate object. I'd like to disable this behaviour (I had a difficult to debug issue because something was auto-bound instead of picking up my custom binding in a module). This question hints that it is possible, but I'm unable to find the answer from the NInject wiki. 回答1: Remove the SelfBindingResolver from the kernel components

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

Using default parameter values with Ninject 3.0

試著忘記壹切 提交于 2019-11-30 18:23:30
I have a class with a constructor having a parameter with a default value. With Ninject 2.2, it would honor the [Optional] attribute and work fine with no binding defined against a constructor declared like so: public EmployeeValidator([Optional] IValidator<PersonName> personNameValidator = null) Since upgrading to Ninject 3.0, construction of this object fails with a message stating that the provider returned null: Test method ValidatorIsolated.Tests.EmployeeValidatorTest.CreateEmployeeValidatorTest threw exception: Ninject.ActivationException: Error activating IValidator{PersonName} using

Is it possible to bind different interfaces to the same instance of a class implementing all of them?

萝らか妹 提交于 2019-11-27 13:26:35
I have the following (simplified) situation: I have two interfaces interface IAmAnInterface { void DoSomething(); } and interface IAmAnInterfaceToo { void DoSomethingElse(); } and a class implementing both: class IAmAnImplementation: IAmAnInterface, IAmAnInterfaceToo { public IAmAnImplementation() { } public void DoSomething() { } public void DoSomethingElse() { } } Now I bind the same class to both interfaces using Ninject. Since I want the same instance of IAmAnImplementation beeing used for IAmAnInterface as well as IAmAnInterfaceToo it's clear that I need some kind of singleton. I played

Is it possible to bind different interfaces to the same instance of a class implementing all of them?

不想你离开。 提交于 2019-11-26 16:21:22
问题 I have the following (simplified) situation: I have two interfaces interface IAmAnInterface { void DoSomething(); } and interface IAmAnInterfaceToo { void DoSomethingElse(); } and a class implementing both: class IAmAnImplementation: IAmAnInterface, IAmAnInterfaceToo { public IAmAnImplementation() { } public void DoSomething() { } public void DoSomethingElse() { } } Now I bind the same class to both interfaces using Ninject. Since I want the same instance of IAmAnImplementation beeing used