[Change]
Due to a bit more complex than was necessary at the original post - my apologies for this - I will try to simplify a bit.
Initially, I had a base class that looked like this:
public class OurViewModel { public bool Validate(ModelStateDictionary modelState){...} }
My class inherited and hid this method using the new keyword:
public class MyViewModel : OurViewModel { public new bool Validate(ModelStateDictionary modelState) {...} }
Meanwhile, the IValidatableObject interface has appeared:
public interface IValidatableObject { IEnumerable<ValidationResult> Validate(ValidationContext validationContext); }
Now, OurViewModel (unfortunately) has also been changed. It looks like this:
public class OurViewModel : IValidatableObject { IEnumerable<ValidationResult> IValidatableObject.Validate(ValidationContext validationContext) {..} }
Now I need to hide the Validate method in MyViewModel again, but I cannot figure out how to do this with the current layout. Is there a good way around this?
(FWIW, I agree that adding a new interface to the base class is not the best way to do something, but this is what happened here.)
[Original post]
I have problems with overriding a method in one of my classes. Someone changed the base class inheritance model:
public class OurViewModel : IntlViewModelBase<OurResources>
:
public class OurViewModel : IntlViewModelBase<OurResources>, IValidatableObject
IValidatableObject has the signature of one method, Validate() :
IEnumerable<ValidationResult> Validate(ValidationContext validationContext);
OurViewModel had a Validate method that looked like this:
public bool Validate(ModelStateDictionary modelState)
... and now this is after the change:
IEnumerable<ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
My class, meanwhile, inherits from OurViewModel . He used the new keyword to implement his own boolean version of Validate.
It seems I can no longer hide the Validate method because my class does not implement IValidatableObject. What is the correct way to override this method now?