Reputation: 1644
this is my interfaces and classes:
public interface IWeapon
{
void Shoot();
}
public interface IWarrior
{
void Kill();
}
public class Killer : IWarrior
{
private static IWeapon _weapon;
public void Kill()
{
_weapon.Shoot();
}
}
public class Rifle : IWeapon
{
public void Shoot()
{
}
}
How I can inject Rifle in Killer class with Ninject?
Upvotes: 0
Views: 686
Reputation: 32725
Ninject does not inject statics because this should be done using InSingletonScope. It does not support field injection too, because fields should not be accessed from outside a class. Use constructor or property injection instead.
Upvotes: 2