I can't think a way to create view for inheritance hierarchy. If I create class hierarchy as in the code below, than I can't use methods and properties of the B class properly from BView.Set(...) without casting , because BView is inherited from AView. And Set method signature accepts variables of A type, but in BView I wish to Set B type variables. How can I solve my issue?
public class A
{
public int id;
public int received;
}
public class B:A
{
public DateTime date;
//... other fields and properties
public void SomeMethod();
//... other methods
}
public interface IView<T>
{
T Source{get;}
void Init(T source);
void Display(bool isOn);
bool IsActive();
}
public class AView : IView<A>
{
public A Source{get; private set;}
public void Set(A source){
Source = source;
}
}
public class BView : AView
{
///???
}
Thank you. :3