Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

trying to store a pointer to my presenter in view class

Posted on 2013-06-20
1
Medium Priority
?
239 Views
Last Modified: 2013-06-24
Here's my presenter class:

public class ListPresenter<TViewInterface, TContext> : Presenter<TViewInterface, TContext>
            where TViewInterface : IContextView<TContext>, IListView
            where TContext : IObservableObject
{
     protected override void OnInitializePresentationComplete(dynamic data)
     {
      View.ViewPresenter = (ListPresenter<TViewInterface, TContext>)this;
     }
}

Here's how I am defining the property in the view:

public ListPresenter<IListView, IObservableObject> ViewPresenter { get; set; }

The compile time exception showing on the ViewPresenter property is "The type IListView cannot be used as type parameter TViewInterface in the generic type or method ListPresenter<TViewInterface, TContect>.  There is no implicit reference conversion from IListView to IContextview<IObservableObject>.

Am I defining the ViewPresenter incorrectly?  Or am I not casting it correctly?  Or both?
0
Comment
Question by:FrancineTaylor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 1

Accepted Solution

by:
FrancineTaylor earned 0 total points
ID: 39272174
I finally figured out how to do what I needed to.  I wanted to give my view direct access to methods in the presenter, but what I was missing was the presenter contract.  I defined an interface for the presenter, IListPresenter, and had the presenter inherit from it.  After that it became simple to cast the presenter and store the pointer.

So my presenter definition now looks like this:

public class ListPresenter<TViewInterface, TContext> : Presenter<TViewInterface, TContext>, IListPresenter
      where TViewInterface : IContextView<TContext>, IListView
      where TContext : IObservableObject
{
      public ListPresenter()
      {
            View.ViewPresenter = (IListPresenter)this;
      }

...and the base view's property...

public IListPresenter ViewPresenter { get; set; }
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question