I have a problem and not so sure how to solve it..
Consider the class:
public class BaseClass<T>
{
public T PreviousInstance { get; set; }
}
Now my secondary data class:
public class DataClass : BaseClass<DataClass>
{
public bool ABoolProperty { get; set; }
}
So i have DataClass (which is populated through a LINQ To WMI bridge on when a WMI object changes) when populated from a change event provides the changed data and the previous data before the edit which works great. I now have a third class:
public class DerivedDataClass : DataClass
{
public string AStringProperty { get; set; }
}
My problem is that DerviedDataClass.PreviousInstance is still of type DataClass, which means i wont get any properties for PreviousInstance that are declared in DerivedDataClass.
I have thought about declaring DataClass ie
public class DataClass<T> : BaseClass<T>
Which would allow the properties from DerivedDataClass to be available in PreviousInstance. However i still need to be able to use DataClass on its own without having to declare it like:
DataClass<DataClass<object>>
just to get it to work what i would really like is to have a generic version of the class and a non generic version, with out having to declare 2 seperate classes with the same properties.
So any ideas? :)