mercredi 18 novembre 2015

Conditional Inheritance of properties

I am making a custom TextBox control. In this control i am creating some interfaces (or it could be a class as well) where i am adding some properties like:

public interface IErrorMsgIsEmpty
{
    string _ErrorMsg
    {
        get;
        set;
    }
}

Now there could be more validations later like:

public interface IRegexValidated
{
    string _RegexMsg
    {
        get;
        set;
    }
}

And so on. What i want to be able to do is that when i implement these Interfaces in my control - the choice of attributes to select from the interface should be conditional, because in some situations - i will need the Regex validation, in some situations i will not and in some situations i may need both. So how can i enforce field selection at compile time itself?

Aucun commentaire:

Enregistrer un commentaire