Table of Contents

Class NamedValue

Namespace
Pamoja.Native.Interop
Assembly
Pamoja.Native.dll

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

value TEnum

The argument.

name string

The argument's name, for the exception.

Returns

TEnum

The argument, unchanged.

Type Parameters

TEnum

The enum type.

Exceptions

ArgumentOutOfRangeException

value is not one of TEnum's named values.