Incorporating multiple validation techniques
Now that we've had a good look at the two validation interfaces, the data annotation attributes and the ability to validate with different levels, let's take a look at how we can amalgamate these different techniques together.
Let's create a BaseNotifyValidationModel
class by copying what we have in our previous implementation, to incorporate these new additions. First, we need to add some extra using directives to the ones used in the previous implementation:
using System.Collections.ObjectModel; using System.Collections.Specialized; using System.ComponentModel.DataAnnotations; using CompanyName.ApplicationName.DataModels.Enums;
Next, we need to add our validationLevel
and errors
fields:
private ValidationLevel ...
Get Mastering Windows Presentation Foundation now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.