Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 56421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:31:55+00:00 2026-05-10T17:31:55+00:00

using MVP, what is the normal order of construction and dependency injection. normally you

  • 0

using MVP, what is the normal order of construction and dependency injection.

normally you create a presenter for each view and pass the view into the presenter on constructor. But what if you have:

  1. A Service that multiple views need to listen to events on.
  2. Multiple views all pointing to the same data model cache.

can someone display a normal flow of info from a user click to data coming back in a service from a server.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T17:31:55+00:00Added an answer on May 10, 2026 at 5:31 pm

    Here is what I do:

    First, I define theses interfaces:

    public interface IView<TPresenter> {     TPresenter Presenter { get; set; } }  public interface IPresenter<TView, TPresenter>     where TView : IView<TPresenter>     where TPresenter : IPresenter<TView, TPresenter> {     TView View { get; set; } } 

    Then this abstract presenter class:

    public abstract class AbstractPresenter<TView, TPresenter> : IPresenter<TView, TPresenter>     where TView : IView<TPresenter>     where TPresenter : class, IPresenter<TView, TPresenter> {     protected TView view;      public TView View     {         get { return this.view; }         set         {             this.view = value;             this.view.Presenter = this as TPresenter;         }     } } 

    The view is injected via a property, instead of the constructor, to allow the bi-directional affection in the setter. Notice that a safe cast is needed…

    Then, my concrete presenter is something like :

    public class MyPresenter : AbstractPresenter<IMyView, MyPresenter> {     //... } 

    Where IMyView implements IView. A concrete view type must exists (e.g. MyView), but it’s the container that resolves it:

    1. I register MyPresenter type as itself in the container, with a transient behavior.
    2. I register MyView as an IMyView in the container with a transient behavior.
    3. I then asks for a MyPresenter to the container.
    4. Container instanciate a MyView
    5. It instanciates a MyPresenter
    6. It inject the view into the presenter through the AbstractPresenter.View property.
    7. The setter code completes the bi-directional association
    8. The container returns the couple Presenter/View

    It allows you to inject other dependencies (services, repos) into both your view and your presenter. But in the scenario you described, I recommend you to inject services and caches into the presenter, instead of the view.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I create windows form application using MVP design pattern. Example: IViewInterface view = new
I've set up a little n-tier web application using MVP (Model View Presenter) in
how populate ComboBox and DataGridView using MVP (Model-View-Presenter). Actually i have something like this:
In my application, using MVP pattern, presenter is setting some properties on view.For example,
We're using the MVP design pattern here, and we've gone with the presenter-per-UserControl style.
I am using the MVP design pattern and I have registered my presenter as
I'm using WebForms MVP to create some simple reporting applications. Most of these applications
I'm trying to create a kind of master/detail UI using an MVP pattern. I
I'm using MVP pattern, so I have a View that has almost no logic
Here's my attempt at using MVP (or Passive View more specifically?) with a MonoDroid

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.