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
파일 보기 프로젝트 열기: XamlBrewer/UWP-Prism-Validation-Sample

공개 프로퍼티들

프로퍼티 타입 설명
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