C# Класс ExpressiveAnnotations.Attributes.ExpressiveAttribute

Наследование: System.ComponentModel.DataAnnotations.ValidationAttribute
Показать файл Открыть проект

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

Метод Описание
Compile ( Type validationContextType, bool force = false ) : void

Parses and compiles expression provided to the attribute. Compiled lambda is then cached and used for validation purposes.

Equals ( object obj ) : bool

Determines whether the specified System.Object, is equal to this instance.

FormatErrorMessage ( string displayName, string expression, Type objectType, Guid>.IDictionary &fieldsMap ) : string

Formats the error message for client (value indicators not resolved - replaced by guids to be dynamically extracted by client-code).

This method interprets custom format specifiers, provided to error message string, for which values or display names of model fields are extracted. Specifiers should be given in braces (curly brackets), i.e. {fieldPath[:indicator]}, e.g. {field}, {field.field:n}. Braces can be escaped by double-braces, i.e. to output a { use {{ and to output a } use }}.

FormatErrorMessage ( string displayName, string expression, object objectInstance ) : string

Formats the error message for user.

This method interprets custom format specifiers, provided to error message string, for which values or display names of model fields are extracted. Specifiers should be given in braces (curly brackets), i.e. {fieldPath[:indicator]}, e.g. {field}, {field.field:n}. Braces can be escaped by double-braces, i.e. to output a { use {{ and to output a } use }}.

GetHashCode ( ) : int

Returns a hash code for this instance.

GetPriority ( ) : int?

Gets the value of Priority if it has been set, or null.

ToString ( ) : string

Returns a System.String that represents this instance.

Защищенные методы

Метод Описание
ExpressiveAttribute ( string expression, Func errorMessageAccessor ) : System

Constructor for expressive validation attribute.

Allows for providing a resource accessor function that will be used to retrieve the error message. An example would be to have something like, e.g. CustomAttribute() : base( () => MyResources.MyErrorMessage ) {}.

ExpressiveAttribute ( string expression, string errorMessage ) : System

Constructor for expressive validation attribute.

IsValid ( object value, System.ComponentModel.DataAnnotations.ValidationContext validationContext ) : System.ComponentModel.DataAnnotations.ValidationResult

Validates a specified value with respect to the associated validation attribute.

IsValidInternal ( object value, System.ComponentModel.DataAnnotations.ValidationContext validationContext ) : System.ComponentModel.DataAnnotations.ValidationResult

Validates a specified value with respect to the associated validation attribute. Internally used by the ExpressiveAttribute.IsValid(object,System.ComponentModel.DataAnnotations.ValidationContext) method.

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

Метод Описание
AdjustMemberName ( System.ComponentModel.DataAnnotations.ValidationContext validationContext ) : void
PreformatMessage ( string displayName, string expression, IList &items ) : string

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

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

Parses and compiles expression provided to the attribute. Compiled lambda is then cached and used for validation purposes.
public Compile ( Type validationContextType, bool force = false ) : void
validationContextType System.Type The type of the object to be validated.
force bool Flag indicating whether parsing should be rerun despite the fact compiled lambda already exists.
Результат void

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

Determines whether the specified System.Object, is equal to this instance.
public Equals ( object obj ) : bool
obj object The to compare with this instance.
Результат bool

ExpressiveAttribute() защищенный Метод

Constructor for expressive validation attribute.
Allows for providing a resource accessor function that will be used to retrieve the error message. An example would be to have something like, e.g. CustomAttribute() : base( () => MyResources.MyErrorMessage ) {}.
expression is null
protected ExpressiveAttribute ( string expression, Func errorMessageAccessor ) : System
expression string The logical expression based on which specified condition is computed.
errorMessageAccessor Func The error message accessor, allowing the error message to be provided dynamically.
Результат System

ExpressiveAttribute() защищенный Метод

Constructor for expressive validation attribute.
expression is null
protected ExpressiveAttribute ( string expression, string errorMessage ) : System
expression string The logical expression based on which specified condition is computed.
errorMessage string The error message to associate with a validation control.
Результат System

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

Formats the error message for client (value indicators not resolved - replaced by guids to be dynamically extracted by client-code).
This method interprets custom format specifiers, provided to error message string, for which values or display names of model fields are extracted. Specifiers should be given in braces (curly brackets), i.e. {fieldPath[:indicator]}, e.g. {field}, {field.field:n}. Braces can be escaped by double-braces, i.e. to output a { use {{ and to output a } use }}.
public FormatErrorMessage ( string displayName, string expression, Type objectType, Guid>.IDictionary &fieldsMap ) : string
displayName string The user-visible name of the required field to include in the formatted message.
expression string The user-visible expression to include in the formatted message.
objectType System.Type The annotated field declaring container type.
fieldsMap Guid>.IDictionary The map containing fields names for which values should be extracted by client-side.
Результат string

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

Formats the error message for user.
This method interprets custom format specifiers, provided to error message string, for which values or display names of model fields are extracted. Specifiers should be given in braces (curly brackets), i.e. {fieldPath[:indicator]}, e.g. {field}, {field.field:n}. Braces can be escaped by double-braces, i.e. to output a { use {{ and to output a } use }}.
public FormatErrorMessage ( string displayName, string expression, object objectInstance ) : string
displayName string The user-visible name of the required field to include in the formatted message.
expression string The user-visible expression to include in the formatted message.
objectInstance object The anotated field declaring container instance.
Результат string

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

Returns a hash code for this instance.
public GetHashCode ( ) : int
Результат int

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

Gets the value of Priority if it has been set, or null.
public GetPriority ( ) : int?
Результат int?

IsValid() защищенный Метод

Validates a specified value with respect to the associated validation attribute.
protected IsValid ( object value, System.ComponentModel.DataAnnotations.ValidationContext validationContext ) : System.ComponentModel.DataAnnotations.ValidationResult
value object The value to validate.
validationContext System.ComponentModel.DataAnnotations.ValidationContext The validation context.
Результат System.ComponentModel.DataAnnotations.ValidationResult

IsValidInternal() защищенный абстрактный Метод

Validates a specified value with respect to the associated validation attribute. Internally used by the ExpressiveAttribute.IsValid(object,System.ComponentModel.DataAnnotations.ValidationContext) method.
protected abstract IsValidInternal ( object value, System.ComponentModel.DataAnnotations.ValidationContext validationContext ) : System.ComponentModel.DataAnnotations.ValidationResult
value object The value to validate.
validationContext System.ComponentModel.DataAnnotations.ValidationContext The validation context.
Результат System.ComponentModel.DataAnnotations.ValidationResult

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

Returns a System.String that represents this instance.
public ToString ( ) : string
Результат string