Here is just a brief idea of ββwhat I found most suitable for our WinForms application architecture (based on MVP).
Each presenter is a constructor depending on the repositories that it needs, for example, if you have an InvoicePresenter, then you have an InvoiceRepository as a dependency, but you will probably have a CustomerRepository and many others depending on complexity (CustomerRepsitory to load all customers in a customer list group if you want to change customer invoices, something like this).
Each repository then has a constuctor argument for UnitOfWork. Either you can abstract the session using the UnitOfWork template, or you can depend on how your replicas depend on ISession.
Everything is connected together by the IoC container, where we create presenters based on the "context". This is a very simple concept, a context for each presenter and all sub-presenters, which, in turn, we create as an integral block of more complex presenters to reduce complexitiy (if, for example, you have several tabs of options for editing an entity or something else).
Thus, in practice, this context is based on a 90% time basis, because one form is at least one presenter / presentation.
So, to answer your questions:
A session for each moderator and conversation session (also works with WinForms) are really useful templates here (and opening closing sessions all over the place, but not a good way to handle this) -
this is best resolved if the repositories are session-dependent rather than leading. You make speakers depend on repositories, repositories depend on a session, and when you create everything, you give them a shared session; but, as I have stated, this is practical only in context. You cannot use the session to compose invoices for the host and other editors; but you can exchange a session when editing an invoice using the main presenter and the details of the invoice and sub-presenter notes.
Please clarify, did not understand this ...
source share