ArgumentHelper..::..AssertEnumMember<(Of <(<'TEnum>)>)> Method (TEnum, array<TEnum>[]()[][])
Assembly: AdvantageCMS.Core (in AdvantageCMS.Core.dll)
Syntax
[DebuggerHiddenAttribute] public static void AssertEnumMember<TEnum>( TEnum enumValue, params TEnum[] validValues ) where TEnum : IConvertible, IConvertible
Type Parameters
- TEnum
- The enumeration type.
Parameters
- enumValue
- Type: TEnum
The value of the enumeration.
- validValues
- Type: array<TEnum>[]()[][]
An array of all valid values.
Remarks
This method can be used to ensure that an enumeration argument is valid for the context of the method. It works for both flags and non-flags enumerations. For flags enumerations, enumValue must be any combination of values specified by validValues. For non-flags enumerations, enumValue must be one of the values specified by validValues.
This method is much faster than the AssertEnumMember(TEnum) overload. This is because it does not use reflection to determine the values defined by the enumeration. For this reason you should prefer this method when validating enumeration arguments.
Another reason why this method is prefered is because it allows you to explicitly specify the values that your code handles. If you use the AssertEnumMember(TEnum) overload and a new value is later added to the enumeration, the assertion will not fail but your code probably will.