RangeAttribute Class
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
[HasConstraint]
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(Int64, Int64) | Initializes a new GreaterThanAttribute and specify an integer bound. |
RangeAttribute(UInt64, UInt64) | Initializes a new GreaterThanAttribute and specify a UInt64 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(). |