I have a Form
with several methods for input validation. I want this validation logic to be shared between several Form
s and UserControl
s. What should be the type of the base class? It cannot be Form
since it will also be used for UserControl
s and it cannot be UserControl
since it will also be used for Form
s.
My instinct tells me that a solution might involve generics, but I am not sure.
Note: By "validation logic" I refer to the implementation, so interfaces are not a solution.
Edit (to make the question a bit clearer): I do have a separate class for actually validating the input. However, I use an ErrorProvider
to indicate the user that the input is invalid. My InputValidator
class calls a method inside the Form
/UserControl
that shows the error to the user, using the ErrorProvider
. I just do not want to copy-paste this method for every Form
/UserControl
.