Class NamedValue
Checks an enum argument before a native call reads it.
public static class NamedValue
- Inheritance
-
NamedValue
- Inherited Members
Remarks
A C# enum can hold any value of its underlying type, such as (PowerMode)7, but
the native library reads an enum as one of the values it declares and has no answer
for any other. A value that is not one of its type's named values is refused here,
before it crosses.
Methods
Require<TEnum>(TEnum, string)
Returns value if it is one of its type's named values.
public static TEnum Require<TEnum>(TEnum value, string name) where TEnum : struct, Enum
Parameters
valueTEnumThe argument.
namestringThe argument's name, for the exception.
Returns
- TEnum
The argument, unchanged.
Type Parameters
TEnumThe enum type.
Exceptions
- ArgumentOutOfRangeException
valueis not one ofTEnum's named values.