Custom attribute that, when added to a field, property or parameter, throws an ArgumentException if the target is assigned a value that is not a valid member of an enumeration.
Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Common.dll
Syntax
public sealed class EnumDataTypeAttribute : LocationContractAttribute, ILocationLevelAspect, IAspectRemarks
Strings are matched against enumeration member names. Integers are matched against enumeration member values. Null values are accepted and do not throw an exception.
The error message is identified by EnumDataTypeErrorMessage.
The error message can use the additional argument {4} to refer to EnumType name.
Constructors
| Name | Description |
|---|---|
| EnumDataTypeAttribute(Type) | Initializes a new instance of the EnumDataTypeAttribute class. |
Properties
| Name | Description |
|---|---|
| EnumType | Gets the enumeration type. |
Methods
| Name | Description |
|---|---|
| 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 |