MetalamaAPI documentationPatterns APIMetalama.​Patterns.​ContractsStrict­Range­Attribute
Open sandboxFocus

StrictRangeAttribute Class

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(Int16, Int16)

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

StrictRangeAttribute(Int32, Int32, Int32)

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

StrictRangeAttribute(Int64, Int64, Int32)

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

StrictRangeAttribute(SByte, SByte)

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

StrictRangeAttribute(Single, Single)

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

StrictRangeAttribute(UInt16, UInt16)

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

StrictRangeAttribute(UInt32, UInt32)

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

StrictRangeAttribute(UInt64, UInt64)

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

Methods

Name Description
OnContractViolated(Object)

See Also