Model-View-Presenter Sample
Here is a small part of my Demo that I’m creating. It is actually a second Presenter with Model and View that are used when you want to import something (the demo will follow so don’t worry ).It gives a good view of how I’m implementing the MVP pattern.
As you can see my Model exists only of methods to get data. My view exists of only events. The presenter has 1 public constructor which takes an IImportModel and IImportView instance. The constructor calls the SetUpView method which will bind all the View’s events to the private methods (ViewAdd, ViewClosing, ViewLoadFeed). The Closing event is an easy feature (WinForms already have this event anyway) which allows me to clean up everything. That’s why the Model also implements the IDisposable interface. So when the view is closed the presenter will call the Dispose method on the Model which can then close the database connection, file or …