C# Class Mvvm.BindableValidator

The BindableValidator class run validation rules of an entity, and stores a collection of errors of the properties that did not pass validation. The validation is run on each property change or whenever the ValidateProperties method is called. It also provides an indexer property, that uses the property names as keys and return the error list for the specified property.
Inheritance: INotifyPropertyChanged
Afficher le fichier Open project: XamlBrewer/UWP-Prism-Validation-Sample

Méthodes publiques

Свойство Type Description
EmptyErrorsCollection ReadOnlyCollection

Méthodes publiques

Méthode Description
BindableValidator ( INotifyPropertyChanged entityToValidate ) : System

Initializes a new instance of the BindableValidator class with the entity to validate.

BindableValidator ( INotifyPropertyChanged entityToValidate, Func getResourceDelegate ) : System

Initializes a new instance of the BindableValidator class with the entity to validate.

GetAllErrors ( ) : ReadOnlyCollection>.ReadOnlyDictionary

Returns a new ReadOnlyDictionary containing all the errors of the Entity, separated by property.

SetAllErrors ( IDictionary entityErrors ) : void

Updates the errors collection of the entity, notifying if the errors collection has changed.

ValidateProperties ( ) : bool

Validates all the properties decorated with the ValidationAttribute attribute. It updates each property errors collection with the new validation results (notifying if necessary).

ValidateProperty ( string propertyName ) : bool

Validates the property, based on the rules set in the property ValidationAttributes attributes. It updates the errors collection with the new validation results (notifying if necessary).

this ( string propertyName ) : ReadOnlyCollection

Returns the errors of the property.

Private Methods

Méthode Description
OnErrorsChanged ( string propertyName ) : void

Notifies listeners that the errors of a property have changed.

OnPropertyChanged ( string propertyName ) : void

Notifies listeners that a property value has changed.

SetPropertyErrors ( string propertyName, IList propertyNewErrors ) : bool

Updates the errors collection of the property.

TryValidateProperty ( PropertyInfo propertyInfo, List propertyErrors ) : bool

Performs a validation of a property, adding the results in the propertyErrors list.

Method Details

BindableValidator() public méthode

Initializes a new instance of the BindableValidator class with the entity to validate.
When is .
public BindableValidator ( INotifyPropertyChanged entityToValidate ) : System
entityToValidate INotifyPropertyChanged The entity to validate
Résultat System

BindableValidator() public méthode

Initializes a new instance of the BindableValidator class with the entity to validate.
When is .
public BindableValidator ( INotifyPropertyChanged entityToValidate, Func getResourceDelegate ) : System
entityToValidate INotifyPropertyChanged The entity to validate
getResourceDelegate Func A delegate that returns a string resource given a resource map Id and resource Id
Résultat System

GetAllErrors() public méthode

Returns a new ReadOnlyDictionary containing all the errors of the Entity, separated by property.
public GetAllErrors ( ) : ReadOnlyCollection>.ReadOnlyDictionary
Résultat ReadOnlyCollection>.ReadOnlyDictionary

SetAllErrors() public méthode

Updates the errors collection of the entity, notifying if the errors collection has changed.
public SetAllErrors ( IDictionary entityErrors ) : void
entityErrors IDictionary The collection of errors for the entity.
Résultat void

ValidateProperties() public méthode

Validates all the properties decorated with the ValidationAttribute attribute. It updates each property errors collection with the new validation results (notifying if necessary).
public ValidateProperties ( ) : bool
Résultat bool

ValidateProperty() public méthode

Validates the property, based on the rules set in the property ValidationAttributes attributes. It updates the errors collection with the new validation results (notifying if necessary).
When is or an empty string value. When the parameter does not match any property name.
public ValidateProperty ( string propertyName ) : bool
propertyName string The name of the property to validate.
Résultat bool

this() public méthode

Returns the errors of the property.
public this ( string propertyName ) : ReadOnlyCollection
propertyName string The name of the property.
Résultat ReadOnlyCollection

Property Details

EmptyErrorsCollection public_oe static_oe property

Represents a collection of empty error values.
public static ReadOnlyCollection EmptyErrorsCollection
Résultat ReadOnlyCollection