AdvantageCMS.Core.Common.BaseClasses Namespace
Advantage CSP

ArgumentHelper..::..AssertEnumMember<(Of <(<'TEnum>)>)> Method (TEnum)

Ensures that enumValue is a valid member of the TEnum enumeration. If it is not, an ArgumentException is thrown.

Namespace:  AdvantageCMS.Core.Common.SitemapGenerator
Assembly:  AdvantageCMS.Core (in AdvantageCMS.Core.dll)

Syntax


[DebuggerHiddenAttribute]
public static void AssertEnumMember<TEnum>(
	TEnum enumValue
)
where TEnum : IConvertible, IConvertible

Type Parameters

TEnum
The enumeration type.

Parameters

enumValue
Type: TEnum
The value of the enumeration.

Exceptions


ExceptionCondition
ArgumentException

Remarks


This method can be used to validate all publicly-supplied enumeration values. Without such an assertion, it is possible to cast any int value to the enumeration type and pass it in.

This method works for both flags and non-flags enumerations. In the case of a flags enumeration, any combination of values in the enumeration is accepted. In the case of a non-flags enumeration, enumValue must be equal to one of the values in the enumeration.

This method is generic and quite slow as a result. You should prefer using the AssertEnumMember(TEnum, params TEnum[]) overload where possible. That overload is both faster and safer. Faster because it does not incur reflection costs, and safer because you are able to specify the exact values accepted by your method.