0

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 thrown 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?

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964

1 Answers1

0

I believe this has to do with your generic where constraints. You're limiting TViewInterface to both IContextView of TContext, and IListView, but this doesn't mean that IListView is an IContextView of TContext, just that whatever type you use is both... Then the error clearly says you're trying to use an IListView as a TViewInterface type, but since it doesn't implement the IContextView interface, it fails.

Haney
  • 32,775
  • 8
  • 59
  • 68