Open sandboxFocus

Class LessThanAttribute

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 a given value.

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

Null values are accepted and do not throw an exception.

The error message is identified by LessThanErrorMessage.

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

Constructors

Name Description
LessThanAttribute(double)

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

LessThanAttribute(long)

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

LessThanAttribute(ulong)

Initializes a new instance of the LessThanAttribute 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.