Open sandboxFocus

Class StrictlyLessThanAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value that is greater than or equal to a given value.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Common.dll
Syntax
public class StrictlyLessThanAttribute : RangeAttribute, ILocationLevelAspect, IValidableAnnotation, IAspect
Remarks

Null values are accepted and do not throw an exception.

A floating-point or decimal value is accepted when it is less than or equal to the greatest value of its type that is less than the bound. A double bound is first converted to decimal, with 15 significant digits, to compute the decimal bound.

The error message is identified by StrictlyLessThanErrorMessage.

The error message can use the additional argument {4} to refer to the maximum value used.

Constructors

Name Description
StrictlyLessThanAttribute(double)

Initializes a new instance of the StrictlyLessThanAttribute class with a given floating-point bound.

StrictlyLessThanAttribute(long)

Initializes a new instance of the StrictlyLessThanAttribute class with a given integer bound.

StrictlyLessThanAttribute(ulong)

Initializes a new instance of the StrictlyLessThanAttribute class with a given ulong bound.

Methods

Name Description
CreateException(object, string, LocationKind, LocationValidationContext)
GetErrorMessage()

Gets the unformatted error message as defined by the instance.

GetErrorMessageArguments()

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