I'm curious about the situation where you have a user control that you want to reuse throughout an application, but you also have a page or other control that also needs a presenter.
So say I have an upload view and control
public partial class UploadControlView : System.Web.UI.UserControl, IUploadView
but I also have a page view
public partial class ExcelProcessorView : System.Web.UI.Page, IExcelProcessorView
The upload control would be on the ExcelProcessor page, so that the user can upload a file which is handed off to some excel processing business logic.
So I have a presenter,
public class ExcelUploadAndProcessPresenter : IUploadPresenter
In the ExcelProcessorView I would wire up the presenter as follows:
protected void Page_Load(object sender, EventArgs e)
{
ExcelUploadAndProcessorPresenter presenter =
new ExcelUploadAndProcessorPresenter(this, uploadControl);
this.AttachPresenter(presenter);
uploadControl.AttachPresenter(presenter);
//init etc...
}
Is this a correct use of the MVP pattern?
I'm trying to figure out what is the best practice for handling a many views to one presenter relationship. Can MVP have a many to one relationship in this fashion. As an alternate question I would also like to know if the MVP pattern can/should handle a situation where you have many presenters and many views (or should you only have one presenter) ?
If you see any problems with my interpretation of MVP in general, by all means go ahead and point that out.
Thanks for reading!