C# 클래스 ExpressiveAnnotations.Attributes.ExpressiveAttribute

상속: System.ComponentModel.DataAnnotations.ValidationAttribute
파일 보기 프로젝트 열기: jwaliszko/ExpressiveAnnotations

공개 메소드들

메소드 설명
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