You should never pass the DI Container around, because then you're using it as a Service Locator, which is an anti-pattern.
If your ApplicationPresenter
requires an AuthenticationPresenter
and an InquiriesManagementPresenter
, then inject those dependencies:
public class ApplicationPresenter : Presenter<IApplicationView>, IApplicationPresenter
{
private readonly static AuthenticationPresenter authenticationPresenter;
private readonly static InquiriesManagementPresenter inquiriesManagementPresenter;
public ApplicationPresenter(
IApplicationView view,
AuthenticationPresenter authenticationPresenter,
InquiriesManagementPresenter inquiriesManagementPresenter)
: base(view)
{
this.authenticationPresenter = authenticationPresenter;
this.inquiriesManagementPresenter = inquiriesManagementPresenter;
View.Connect += OnConnect;
View.ManageInquiries += OnManageInquiries;
}
}
If those presenters have dependencies of their own, it's totally fine: you just build up the entire graph up front, but the AplicationPresenter
doesn't have to see any of the sub-graphs.