I have a generic class that needs to limit an enum depending on the type defined:
public enum ConditionOperatorsString { None, Like, Equal }
public enum ConditionOperatorsDate { None, Equal, BeforeThan, AfterThan }
public class Condition<T>
{
public T Value { get; set; }
public ConditionOperatorsString Operator { get; set; }
public Condition(T Value, ConditionOperatorsString Operator)
{
this.Value = Value;
this.Operator = Operator;
}
}
Now the problem is that i want the Operator type be dependant on T so when:
Condition<string> CStr= new Condition<string>(string.Empty, ConditionOperatorsString.None)
Condition<DateTime> CStr= new Condition<DateTime>(DateTime.Now, ConditionOperatorsDate.None)
How do I define the class Condition for that? I thought of an interface but enums don't inherit from interfaces.