C# Класс 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.
Наследование: INotifyPropertyChanged
Показать файл Открыть проект

Открытые свойства

Свойство Тип Описание
EmptyErrorsCollection ReadOnlyCollection

Открытые методы

Метод Описание
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.

Приватные методы

Метод Описание
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.

Описание методов

BindableValidator() публичный Метод

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
Результат System

BindableValidator() публичный Метод

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
Результат System

GetAllErrors() публичный Метод

Returns a new ReadOnlyDictionary containing all the errors of the Entity, separated by property.
public GetAllErrors ( ) : ReadOnlyCollection>.ReadOnlyDictionary
Результат ReadOnlyCollection>.ReadOnlyDictionary

SetAllErrors() публичный Метод

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.
Результат void

ValidateProperties() публичный Метод

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
Результат bool

ValidateProperty() публичный Метод

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.
Результат bool

this() публичный Метод

Returns the errors of the property.
public this ( string propertyName ) : ReadOnlyCollection
propertyName string The name of the property.
Результат ReadOnlyCollection

Описание свойств

EmptyErrorsCollection публичное статическое свойство

Represents a collection of empty error values.
public static ReadOnlyCollection EmptyErrorsCollection
Результат ReadOnlyCollection