Open sandboxFocus

Class StrictRangeAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value that is not strictly within the given range.

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

Null values are accepted and do not throw an exception.

Floating-point values are tested to be strictly within the given bounds with a tolerance value. The tolerance value is equal to the distance of the value closest to the bounds according to the precision of the respective floating-point numerical data type.

Constructors

Name Description
StrictRangeAttribute(byte, byte)

Initializes a new instance of the StrictRangeAttribute class specifying bounds of type byte.

StrictRangeAttribute(decimal, decimal)

Initializes a new instance of the StrictRangeAttribute class specifying bounds of type decimal.

StrictRangeAttribute(double, double)

Initializes a new instance of the StrictRangeAttribute class specifying bounds of type double.

StrictRangeAttribute(short, short)

Initializes a new instance of the StrictRangeAttribute class specifying bounds of type short.

StrictRangeAttribute(int, int, int)

Initializes a new instance of the StrictRangeAttribute class specifying bounds of type int.

StrictRangeAttribute(long, long, int)

Initializes a new instance of the StrictRangeAttribute class specifying bounds of type long.

StrictRangeAttribute(sbyte, sbyte)

Initializes a new instance of the StrictRangeAttribute class specifying bounds of type sbyte.

StrictRangeAttribute(float, float)

Initializes a new instance of the StrictRangeAttribute class specifying bounds of type float.

StrictRangeAttribute(ushort, ushort)

Initializes a new instance of the StrictRangeAttribute class specifying bounds of type ushort.

StrictRangeAttribute(uint, uint)

Initializes a new instance of the StrictRangeAttribute class specifying bounds of type uint.

StrictRangeAttribute(ulong, ulong)

Initializes a new instance of the StrictRangeAttribute class specifying bounds of type ulong.

Methods

Name Description
OnContractViolated(dynamic?, NumericRange, ContractContext)

See Also