Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value that is outside a given range.
Inheritance
Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Common.dll
Syntax
public class RangeAttribute : LocationContractAttribute, ILocationLevelAspect, IValidableAnnotation, IAspect
Remarks
Null values are accepted and do not throw an exception.
Error message is identified by RangeErrorMessage.
Error message can use additional argument
Constructors
Name | Description |
---|---|
RangeAttribute(double, double) | Initializes a new GreaterThanAttribute and specify a floating-point bound. |
RangeAttribute(long, long) | Initializes a new GreaterThanAttribute and specify an integer bound. |
RangeAttribute(ulong, ulong) | Initializes a new GreaterThanAttribute and specify a ulong bound. |
Properties
Name | Description |
---|---|
DisplayMaxValue | Gets the maximal value to be used when generating the error message, typically in the implementation of GetErrorMessageArguments(). |
DisplayMinValue | Gets the minimal value to be used when generating the error message, typically in the implementation of GetErrorMessageArguments(). |
Methods
Name | Description |
---|---|
CompileTimeValidate(object) | Method invoked at build time to ensure that the aspect has been applied to the right target. |
CreateException(object, string, LocationKind, LocationValidationContext) | |
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 |
ValidateValueDynamic(object, string, LocationKind, LocationValidationContext) | Validates a weakly-typed (boxed) value, typically the value of a dependency property or an attached property. |