Open sandboxFocus

Class GreaterThanAttribute

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

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

Null values are accepted and do not throw an exception.

The error message is identified by GreaterThanErrorMessage.

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

Constructors

Name Description
GreaterThanAttribute(double)

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

GreaterThanAttribute(long)

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

GreaterThanAttribute(ulong)

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