public interface IBasePresenter
{
}
public interface IJobViewPresenter : IBasePresenter
{
}
public interface IActivityViewPresenter : IBasePresenter
{
}
public clas
This is a job for polymorphism.
public interface IBasePresenter
{
}
public interface IJobViewPresenter : IBasePresenter
{
}
public interface IActivityViewPresenter : IBasePresenter
{
}
public class BaseView : IBasePresenter
{
}
public class JobView : BaseView, IJobViewPresenter
{
}
public class ActivityView : BaseView, IActivityViewPresenter
{
}
You can do this:
public class BaseView<TPresenter>
where TPresenter: IBasePresenter
{
TPresenter Presenter { get; set; }
}
public class JobView: BaseView<IJobViewPresenter>
{
}
If you have code that needs to reference BaseView, you can create an interface and expose the base presenter like this:
public interface IBaseView
{
IBasePresenter BasePresenter { get; }
}
public class BaseView<TPresenter> : IBaseView
where TPresenter: IBasePresenter
{
TPresenter Presenter { get; set; }
IBasePresenter IBaseView.BasePresenter
{
get { return Presenter; }
}
}
Classes that need access to the BaseView can now consume the interface instead of BaseView directly. You can expose any other base services that need to be consumed in there as well.