我如何在 Asp.Net Core 中使用 Ninject?
How can I use Ninject in Asp.Net Core?
我已经在 stratup.cs 中注册了我的模块,我想在构造函数中使用依赖注入而不使用参数。
public class AdherentManager
{
private readonly IAdherentRepository _adherentRepository;
public AdherentManager()
{
_adherentRepository = // how can i inject without using the arugments.
}
public void AddAdherent(Adherent pAdherent)
{
_adherentRepository.Insert(pAdherent);
}
}
尝试在构造函数中实例化
_adherentRepository = new IAdherentRepository();
我已经在 stratup.cs 中注册了我的模块,我想在构造函数中使用依赖注入而不使用参数。
public class AdherentManager
{
private readonly IAdherentRepository _adherentRepository;
public AdherentManager()
{
_adherentRepository = // how can i inject without using the arugments.
}
public void AddAdherent(Adherent pAdherent)
{
_adherentRepository.Insert(pAdherent);
}
}
尝试在构造函数中实例化
_adherentRepository = new IAdherentRepository();