需要一個設計建議。 請參閱下面的課程。 類只有一個方法 類具有將userName和passWord作爲參數的構造方法。 問題是 - 請告訴我區別,如果 - 如果我從構造 刪除用戶名和pwd - 和發送(用戶名,密碼)的AuthoriseUser方法通過構造函數或類方法級別注入依賴關係?
所有這一切都在注入依賴
public class UserNameAuthorisationService : IUserNameAuthorisationService
{
private readonly string _userName;
private readonly string _password;
private readonly IUserNameAuthorisationRepository _usernameAuthRepository;
public UserNameAuthorisationService(string UserName, string Password, IUserNameAuthorisationRepository UsernameAuthRepository)
{
_userName = UserName;
_password = Password;
_usernameAuthRepository = UsernameAuthRepository;
}
public IUser AuthoriseUser()
{
throw new NotImplementedException();
}
}
的背景
在此先感謝。
謝謝雷納託 - 我明白你的意思。 –