PostSharpAPI ReferencePost­Sharp.​Patterns.​ContractsRegular­Expression­Attribute
Open sandboxFocus

Class RegularExpressionAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentException if the target is assigned a value that does not match a given regular expression. Null strings are accepted and do not throw an exception.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Common.dll
Syntax
[HasConstraint]
public class RegularExpressionAttribute : LocationContractAttribute, ILocationLevelAspect, IAspect

Constructors

Name Description
RegularExpressionAttribute(String)

Initializes a new RegularExpressionAttribute.

RegularExpressionAttribute(String, RegexOptions)

Initializes a new RegularExpressionAttribute and specify options.

Methods

Name Description
GetErrorMessage()

Gets unformatted error message as defined by the instance.

GetErrorMessageArguments()

Gets values of additional arguments for error message associated with particular instance of LocationContractAttribute. There arguments can be referenced from error message string by {4}, {5} and so on.

ValidateValue(String, String, LocationKind, LocationValidationContext)
ValidateValueDynamic(Object, String, LocationKind, LocationValidationContext)

Validates a weakly-typed (boxed) value, typically the value of a dependency property or an attached property.