How does one build an application (Gtk/Winforms) with MVP pattern with nested presenters? I cannot manage to get it right开发者_开发知识库.
Lets say I have a main window (application shell) with a treeview (navigator presenter) and a panel (profile presenter), and want each of those 3 to be separate MVP-components?
public class ApplicationShellPresenter(IApplicationShellView shell);
public class NavigatorPresenter(INavigatorView navigator);
public class ProfilePresenter(IProfileView profile);
The first presenter is easy because I can create the main window in the composition root and inject in the constructor, but the other two, who creates them? The views are already created insde the main window. From what I can see I have two possibilities, the application shell creates them or I expose the views through ApplicationShellPresenter and create them somewhere else.
And to make things even more complicated, how do I use an IoC-container in all of this, to resolve presenters, views ?
Is my problem constructor injection? Should I introduce Init-methods instead to be able to create presenters without their corresponding views?
Any thoughts on this would be appreciated.
I solved it, the problem was actually having constructor injection. I simply created a get/set property on my base presenter and I was good to go.
精彩评论