model - GUI Design Pattern , MVP, Tab Control -
I have an application that has the same word as window.
The requirement here is that when the user clicks the Save button, everything should be saved "Save" and "Reset" on all tabs "Button" is normal, "therefore, when the" personal information "tab is selected and click" Save ", then changes made in the program" Friends "tab and also the changes made in the" Employment history "tab should also be saved. .
The app already contains the code and I want to keep this code:
- View personal information, personal information display, personal information model
- Friends view, friend viewer , Friendship
- View Employment History, Employer Event Projector, Employorial Histim Modell
Each presenter has an Save method.
The question is, to take into account a good design pattern that I want to keep keep that code already, in addition to this, I want to do as well as the presenter. Or maybe I should repeat your question a bit: What is the best way to include "sub-view", "sub-presenter" programming MVP ?
Regards, Madsub
I will bring your new presenter to their sub-presenters As a producer argument, something like:
class DialogPresenter {Private Readonly IDialogView view; Personal ReDonline personal informationperson personal; Private Readonly Friend Friend; History of the Private Reidonly Emporium History; Zero Dialogue Presentation (View IDialogView, Personal Information Viewer Personal, Friend Friend, Employment History Editor History) {this.view = view; this. Personal = personal; this. Friends = friends; This.history = history; } Bool display () {this.personal.Display (); This.friends.Display (); This.history.Display (); Return this to return.view.Display () == DialogResult.Ok; } Save Zero () {this.personal.Save (); This.friends.Save (); This.history.Save (); Of course, if there was a general interface between your presenters, then this could be simpler (more can be increased) such as: class DialogPresenter {Private Readonly IDialogView view; Private readonly ipjester [] presenter; Zero dialog presentation (IDialogView view, IP rendering [] presenter) {this.view = view; this. Presenter = Presenter; } Bool Display () {foreach (different items in this item) items Display (); Return this to return.view.Display () == DialogResult.Ok; } Save zero () {var Valid = New list & lt; String & gt; (); Foreign exchange (item item in this.) Verification. AddRange (item.Validate ()); If (validation.account> 0) {_view.ShowErrors (verification); Return; } Foreach (var items in this presenters) Verification. AddRange (item.Save ()); }}
Edit: The calling code will be something like this:
Zero DisplayForm () {(var frm = new frmDisplay) {// Use only DI to use model var personal = new personal information viewer (Personal Model, frm.PersonalTab); // Some qualities to expose your thoughts = friends of friends = new friends (friends's memold, FRM.FriendsTab); Var History = New Employment History Viewer (Employment History Model, frm.HistoryTab); Var presenter = new dialog presentation (FMM, personal, friend, history); If (presenter. Display ()) {presenter.Save (); }}}
Hopefully some inapassment / help is done :)
Comments
Post a Comment