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 bound. The behavior when the target is exactly assigned to the bound depends on the DefaultInequalityStrictness option. If this option is not specified, a warning is reported.

Namespace: Metalama.Patterns.Contracts
Assembly: Metalama.Patterns.Contracts.dll
Syntax
public class LessThanAttribute : RangeAttribute, IAspect<IParameter>, IEligible<IParameter>, IAspect<IFieldOrPropertyOrIndexer>, IEligible<IFieldOrPropertyOrIndexer>, IConditionallyInheritableAspect, IAspect, ICompileTimeSerializable, ITemplateProvider
Remarks

Null values are accepted and do not throw an exception.

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

Constructors

Name Description
LessThanAttribute(byte)

Initializes a new instance of the LessThanAttribute class specifying a maximum value of type byte.

LessThanAttribute(decimal)

Initializes a new instance of the LessThanAttribute class specifying a maximum value of type decimal.

LessThanAttribute(double)

Initializes a new instance of the LessThanAttribute class specifying a maximum value of type double.

LessThanAttribute(short)

Initializes a new instance of the LessThanAttribute class specifying a maximum value of type short.

LessThanAttribute(int, int)

Initializes a new instance of the LessThanAttribute class specifying a maximum value of type int.

LessThanAttribute(long, int)

Initializes a new instance of the LessThanAttribute class specifying a maximum value of type long.

LessThanAttribute(sbyte)

Initializes a new instance of the LessThanAttribute class specifying a maximum value of type sbyte.

LessThanAttribute(float)

Initializes a new instance of the LessThanAttribute class specifying a maximum value of type float.

LessThanAttribute(ushort)

Initializes a new instance of the LessThanAttribute class specifying a maximum value of type ushort.

LessThanAttribute(uint)

Initializes a new instance of the LessThanAttribute class specifying a maximum value of type uint.

LessThanAttribute(ulong)

Initializes a new instance of the LessThanAttribute class specifying a maximum value of type ulong.

Methods

Name Description
OnContractViolated(dynamic?, NumericRange, ContractContext)

Extension Methods

See Also