I used to code in ASP.Net MVC, now I have a WinForms project. I read that MVP pattern is best for WinForms. But, I'm confused on how to inject multiple dependencies into Presenter.
For example I need to load a view called "UserLoginView". The presenter requires 3 parameters.
public partial class UserLoginView : IUserLoginView
{
public event Action OnFormLoad;
private UserLoginPresenter _userLoginPresenter;
public UserLoginView()
{
InitializeComponent();
//This is my problem
var userService = EngineContext.Current.Resolve<IUserService>();
var authenticationService = EngineContext.Current.Resolve<IAuthenticationService>();
_userLoginPresenter = new UserLoginPresenter(this, userService,
authenticationService);
}
}
public class UserLoginPresenter
{
private readonly IUserLoginView view;
private readonly IUserService _userService;
private readonly IAuthenticationService _authenticationService;
public UserLoginPresenter(IUserLoginView userLoginView,
IUserService userService,
IAuthenticationService authenticationService)
{
this.view = userLoginView;
this._userService = userService;
this._authenticationService = authenticationService;
}
...
What is the right way to inject dependencies to presenter?
Please I need a hand guys. Thank you.