Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ IsEnumDefined()

override bool System.RuntimeType.IsEnumDefined ( object value)
inlinevirtual

Reimplemented from System.Type.

Definition at line 3570 of file RuntimeType.cs.

3571 {
3572 if (value == null)
3573 {
3574 throw new ArgumentNullException("value");
3575 }
3576 if (!IsEnum)
3577 {
3578 throw new ArgumentException(SR.Arg_MustBeEnum, "enumType");
3579 }
3581 if (runtimeType.IsEnum)
3582 {
3583 if (!runtimeType.IsEquivalentTo(this))
3584 {
3585 throw new ArgumentException(SR.Format(SR.Arg_EnumAndObjectMustBeSameType, runtimeType, this));
3586 }
3587 runtimeType = (RuntimeType)runtimeType.GetEnumUnderlyingType();
3588 }
3589 if (runtimeType == StringType)
3590 {
3591 string[] array = Enum.InternalGetNames(this);
3592 object[] array2 = array;
3593 return Array.IndexOf(array2, value) >= 0;
3594 }
3595 if (Type.IsIntegerType(runtimeType))
3596 {
3597 RuntimeType runtimeType2 = Enum.InternalGetUnderlyingType(this);
3599 {
3600 throw new ArgumentException(SR.Format(SR.Arg_EnumUnderlyingTypeAndObjectMustBeSameType, runtimeType, runtimeType2));
3601 }
3602 ulong[] array3 = Enum.InternalGetValues(this);
3603 ulong value2 = Enum.ToUInt64(value);
3604 return Array.BinarySearch(array3, value2) >= 0;
3605 }
3606 throw new InvalidOperationException(SR.InvalidOperation_UnknownEnumType);
3607 }
static readonly RuntimeType StringType
virtual bool IsEnum
Definition Type.cs:227

References System.SR.Arg_EnumAndObjectMustBeSameType, System.SR.Arg_EnumUnderlyingTypeAndObjectMustBeSameType, System.SR.Arg_MustBeEnum, System.array, System.Array.BinarySearch(), System.SR.Format(), System.Array.IndexOf(), System.Enum.InternalGetNames(), System.Enum.InternalGetUnderlyingType(), System.Enum.InternalGetValues(), System.SR.InvalidOperation_UnknownEnumType, System.Type.IsIntegerType(), System.Enum.ToUInt64(), and System.value.