I have a class hierarchy, something like this:
public abstract class BaseDecision { // <implementation> } public class CCDecision : BaseDecision { // <implementation> } public class UCDecision : BaseDecision { // <implementation> } public abstract class BaseInfo<TDecision> where TDecision:BaseDecision, new() { public TDecision proposedDecision; public TDecision finalDecision; // <implementation> } public class CCInfo : BaseInfo<CCDecision> { // <implementation> } public class UCInfo : BaseInfo<UCDecision> { // <implementation> }
The problem is that with such a class hierarchy, I cannot declare a variable that can contain instances of the CCInfo and UCInfo classes (since they use the base type with a different type of parameters). As far as I understand, I also can not use dispersion, as my general parameter is used for both input and output.
I personally feel some kind of anti-pattern here, but just can't figure out how to solve this.
source share