I started hugging the whole MVP pattern , and while I am doing a great job with single objects, it starts to get complicated when it comes to collections.
So, let's say, we are developing a simple WinForms application consisting of a DataGrid in the form, while the data model is a simple collection of things where such things have a bunch of properties, and the view will actually display them:
Model
public class Person
{
public string Name { get; set; }
public DateTime Birth { get; set; }
public bool IsCool { get; set; }
}
public class People
{
public List<Person> Persons { get; set; }
}
View
public interface IPeopleView
{
List<People> ListOfPeople { get; set; }
}
public partial class PeopleViewImpl : Form, IPeopleView
{
private DataGridView _grid = new DataGridView();
public PeopleViewImpl()
{
InitializeComponent();
}
public List<People> ListOfPeople
{
get { return ; }
set { _grid.DataSource = value; }
}
}
Presenter
public class PeoplePresenter
{
private People _model;
private IPeopleView _view;
public PeoplePresenter(People model, IPeopleView view)
{
_model = model;
_view = view;
}
void UpdateView()
{
_view.ListOfPeople = _model.Peoples;
}
}
So, what should I implement in the List<People> ListOfPeoplegetter view , as well as how do I call Presenter UpdateView()?
, Presenter MVP ?
, . .