我继承了一些代码,其中有一个名为AuthenticationManager的类,它包含所有静态方法。
我正在引入DI(依赖注入)并希望添加一个构造函数,该构造函数需要一个依赖项UserController。
UserController _userController;
public AuthenticationManager(UserController userCont)
{
_userController = userCont;
}
现在我遇到编译时错误,提示非静态变量从静态方法引用。您对于最小程度修改此类和调用代码的最佳实践建议是什么?
我们正在使用SimpleServiceLocator作为IOC容器。