MetalamaAPI documentationPatterns APIMetalama.​Patterns.​ContractsRange­Attribute
Open sandboxFocus

RangeAttribute Class

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

Namespace: Metalama.Patterns.Contracts
Assembly: Metalama.Patterns.Contracts.dll
Syntax
public class RangeAttribute : ContractBaseAttribute, 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 and {5} to refer to the maximum value used.

Constructors

Name Description
RangeAttribute(Double, Double)

Initializes a new instance of the RangeAttribute class specifying floating-point bounds.

RangeAttribute(Int64, Int64)

Initializes a new instance of the RangeAttribute class specifying integer bounds.

RangeAttribute(UInt64, UInt64)

Initializes a new instance of the RangeAttribute class specifying unsigned integer bounds.

Properties

Name Description
DisplayMaxValue

Gets the maximal value to be used when generating the error message.

DisplayMinValue

Gets the minimal value to be used when generating the error message.

Methods

Name Description
BuildAspect(IAspectBuilder<IFieldOrPropertyOrIndexer>)
BuildAspect(IAspectBuilder<IParameter>)
BuildEligibility(IEligibilityBuilder<IFieldOrPropertyOrIndexer>)
BuildEligibility(IEligibilityBuilder<IParameter>)
OnContractViolated(Object)
Validate(Object)