As an experiment, I'm trying to write a general MVP structure.
I started with:
public interface IPresenter<TView> where TView: IView<IPresenter<...
{
TView View { get; set;}
}
public interface IView<TPresenter> where TPresenter:IPresenter<IView<...
{
TPresenter Presenter { get; set; }
}
It is obvious that this is impossible, because the types TViewand TPresentercan not be resolved. You write Type<Type<...forever. So, my next attempt looked like this:
public interface IView<T> where T:IPresenter
{
...
}
public interface IView:IView<IPresenter>
{
}
public interface IPresenter<TView> where TView: IView
{
...
}
public interface IPresenter: IPresenter<IView>
{
...
}
It actually compiles, and you can even inherit from interfaces such as this:
public class MyView : IView, IView<MyPresenter>
{
...
}
public class MyPresenter : IPresenter, IPresenter<MyView>
{
...
}
, , . , . , . , . ? ?