Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't see how <code>(TView)this</code> is expected to work. <code>this</code> is referring to the class which happens to be a <code>Page</code>. You can't convert a <code>Page</code> to an <code>IView</code>.</p> <p>Your current implementation doesn't look at all hacky.</p> <p>Am I missing something?</p> <p><strong>EDIT:</strong> now that I understand your situation a little better; what about having ViewBasePage inherit from IView (And removing it from your _Default page)?</p> <p><strong>EDIT</strong> Furthermore, if you then want the _Default page to have to implement the functions defined in the Interface, you can have the ViewBasePage class implement the interface's functions abstractly.</p> <pre><code>public class _Default : ViewBasePage&lt;Presenter&lt;IView&gt;, IView&gt; { #region Overrides of classB public override void test() { //perform the test steps. } #endregion } public abstract class ViewBasePage&lt;TPresenter, TView&gt; : Page, IView where TPresenter : Presenter&lt;TView&gt; where TView : IView { protected TPresenter _presenter; public TPresenter Presenter { set { _presenter = value; _presenter.View = (TView)((IView)this); //&lt;- Now it does work } } #region Implementation of IView public abstract void test(); #endregion } public interface IView { void test(); } public abstract class Presenter&lt;TView&gt; where TView : IView { public TView View { get; set; } public virtual void OnViewInitialized(){} public virtual void OnViewLoaded(){} } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload