using System; using System.Collections; using System.Globalization; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace System { /// Provides the base class for enumerations. /// 2 // Token: 0x02000028 RID: 40 [ComVisible(true)] [Serializable] public abstract class Enum : ValueType, IFormattable, IConvertible, IComparable { /// Converts the current value to a Boolean value based on the underlying type. /// This member always throws an exception. /// An object that supplies culture-specific formatting information. /// In all cases. // Token: 0x060003B9 RID: 953 RVA: 0x0000E968 File Offset: 0x0000CB68 bool IConvertible.ToBoolean(IFormatProvider provider) { return Convert.ToBoolean(this.Value, provider); } /// Converts the current value to an 8-bit unsigned integer based on the underlying type. /// The converted value. /// An object that supplies culture-specific formatting information. // Token: 0x060003BA RID: 954 RVA: 0x0000E978 File Offset: 0x0000CB78 byte IConvertible.ToByte(IFormatProvider provider) { return Convert.ToByte(this.Value, provider); } /// Converts the current value to a Unicode character based on the underlying type. /// This member always throws an exception. /// An object that supplies culture-specific formatting information. /// In all cases. // Token: 0x060003BB RID: 955 RVA: 0x0000E988 File Offset: 0x0000CB88 char IConvertible.ToChar(IFormatProvider provider) { return Convert.ToChar(this.Value, provider); } /// Converts the current value to a based on the underlying type. /// This member always throws an exception. /// An object that supplies culture-specific formatting information. /// In all cases. // Token: 0x060003BC RID: 956 RVA: 0x0000E998 File Offset: 0x0000CB98 DateTime IConvertible.ToDateTime(IFormatProvider provider) { return Convert.ToDateTime(this.Value, provider); } /// Converts the current value to a based on the underlying type. /// This member always throws an exception. /// An object that supplies culture-specific formatting information. /// In all cases. // Token: 0x060003BD RID: 957 RVA: 0x0000E9A8 File Offset: 0x0000CBA8 decimal IConvertible.ToDecimal(IFormatProvider provider) { return Convert.ToDecimal(this.Value, provider); } /// Converts the current value to a double-precision floating point number based on the underlying type. /// This member always throws an exception. /// An object that supplies culture-specific formatting information. /// In all cases. // Token: 0x060003BE RID: 958 RVA: 0x0000E9B8 File Offset: 0x0000CBB8 double IConvertible.ToDouble(IFormatProvider provider) { return Convert.ToDouble(this.Value, provider); } /// Converts the current value to a 16-bit signed integer based on the underlying type. /// The converted value. /// An object that supplies culture-specific formatting information. // Token: 0x060003BF RID: 959 RVA: 0x0000E9C8 File Offset: 0x0000CBC8 short IConvertible.ToInt16(IFormatProvider provider) { return Convert.ToInt16(this.Value, provider); } /// Converts the current value to a 32-bit signed integer based on the underlying type. /// The converted value. /// An object that supplies culture-specific formatting information. // Token: 0x060003C0 RID: 960 RVA: 0x0000E9D8 File Offset: 0x0000CBD8 int IConvertible.ToInt32(IFormatProvider provider) { return Convert.ToInt32(this.Value, provider); } /// Converts the current value to a 64-bit signed integer based on the underlying type. /// The converted value. /// An object that supplies culture-specific formatting information. // Token: 0x060003C1 RID: 961 RVA: 0x0000E9E8 File Offset: 0x0000CBE8 long IConvertible.ToInt64(IFormatProvider provider) { return Convert.ToInt64(this.Value, provider); } /// Converts the current value to an 8-bit signed integer based on the underlying type. /// The converted value. /// An object that supplies culture-specific formatting information. // Token: 0x060003C2 RID: 962 RVA: 0x0000E9F8 File Offset: 0x0000CBF8 sbyte IConvertible.ToSByte(IFormatProvider provider) { return Convert.ToSByte(this.Value, provider); } /// Converts the current value to a single-precision floating point number based on the underlying type. /// This member always throws an exception. /// An object that supplies culture-specific formatting information. /// In all cases. // Token: 0x060003C3 RID: 963 RVA: 0x0000EA08 File Offset: 0x0000CC08 float IConvertible.ToSingle(IFormatProvider provider) { return Convert.ToSingle(this.Value, provider); } /// Converts the current value to a specified type based on the underlying type. /// The converted value. /// The type to convert to. /// An object that supplies culture-specific formatting information. // Token: 0x060003C4 RID: 964 RVA: 0x0000EA18 File Offset: 0x0000CC18 object IConvertible.ToType(Type targetType, IFormatProvider provider) { if (targetType == null) { throw new ArgumentNullException("targetType"); } if (targetType == typeof(string)) { return this.ToString(provider); } return Convert.ToType(this.Value, targetType, provider, false); } /// Converts the current value to a 16-bit unsigned integer based on the underlying type. /// The converted value. /// An object that supplies culture-specific formatting information. // Token: 0x060003C5 RID: 965 RVA: 0x0000EA5C File Offset: 0x0000CC5C ushort IConvertible.ToUInt16(IFormatProvider provider) { return Convert.ToUInt16(this.Value, provider); } /// Converts the current value to a 32-bit unsigned integer based on the underlying type. /// The converted value. /// An object that supplies culture-specific formatting information. // Token: 0x060003C6 RID: 966 RVA: 0x0000EA6C File Offset: 0x0000CC6C uint IConvertible.ToUInt32(IFormatProvider provider) { return Convert.ToUInt32(this.Value, provider); } /// Converts the current value to a 64-bit unsigned integer based on the underlying type. /// The converted value. /// An object that supplies culture-specific formatting information. // Token: 0x060003C7 RID: 967 RVA: 0x0000EA7C File Offset: 0x0000CC7C ulong IConvertible.ToUInt64(IFormatProvider provider) { return Convert.ToUInt64(this.Value, provider); } /// Returns the underlying for this instance. /// The for this instance. /// The enumeration type is unknown. /// 2 // Token: 0x060003C8 RID: 968 RVA: 0x0000EA8C File Offset: 0x0000CC8C public TypeCode GetTypeCode() { return Type.GetTypeCode(Enum.GetUnderlyingType(base.GetType())); } // Token: 0x060003C9 RID: 969 [MethodImpl(MethodImplOptions.InternalCall)] private extern object get_value(); // Token: 0x1700000F RID: 15 // (get) Token: 0x060003CA RID: 970 RVA: 0x0000EAA0 File Offset: 0x0000CCA0 private object Value { get { return this.get_value(); } } /// Retrieves an array of the values of the constants in a specified enumeration. /// An of the values of the constants in . The elements of the array are sorted by the binary values of the enumeration constants. /// An enumeration type. /// /// is null. /// /// is not an . /// 1 // Token: 0x060003CB RID: 971 RVA: 0x0000EAA8 File Offset: 0x0000CCA8 [ComVisible(true)] public static Array GetValues(Type enumType) { if (enumType == null) { throw new ArgumentNullException("enumType"); } if (!enumType.IsEnum) { throw new ArgumentException("enumType is not an Enum type.", "enumType"); } MonoEnumInfo monoEnumInfo; MonoEnumInfo.GetInfo(enumType, out monoEnumInfo); return (Array)monoEnumInfo.values.Clone(); } /// Retrieves an array of the names of the constants in a specified enumeration. /// A string array of the names of the constants in . /// An enumeration type. /// /// is null. /// /// parameter is not an . /// 1 // Token: 0x060003CC RID: 972 RVA: 0x0000EAFC File Offset: 0x0000CCFC [ComVisible(true)] public static string[] GetNames(Type enumType) { if (enumType == null) { throw new ArgumentNullException("enumType"); } if (!enumType.IsEnum) { throw new ArgumentException("enumType is not an Enum type."); } MonoEnumInfo monoEnumInfo; MonoEnumInfo.GetInfo(enumType, out monoEnumInfo); return (string[])monoEnumInfo.names.Clone(); } // Token: 0x060003CD RID: 973 RVA: 0x0000EB4C File Offset: 0x0000CD4C private static int FindPosition(object value, Array values) { if (!(values is byte[]) && !(values is ushort[]) && !(values is uint[]) && !(values is ulong[])) { if (values is int[]) { return Array.BinarySearch(values, value, MonoEnumInfo.int_comparer); } if (values is short[]) { return Array.BinarySearch(values, value, MonoEnumInfo.short_comparer); } if (values is sbyte[]) { return Array.BinarySearch(values, value, MonoEnumInfo.sbyte_comparer); } if (values is long[]) { return Array.BinarySearch(values, value, MonoEnumInfo.long_comparer); } } return Array.BinarySearch(values, value); } /// Retrieves the name of the constant in the specified enumeration that has the specified value. /// A string containing the name of the enumerated constant in whose value is , or null if no such constant is found. /// An enumeration type. /// The value of a particular enumerated constant in terms of its underlying type. /// /// or is null. /// /// is not an .-or- is neither of type nor does it have the same underlying type as . /// 1 // Token: 0x060003CE RID: 974 RVA: 0x0000EBF0 File Offset: 0x0000CDF0 [ComVisible(true)] public static string GetName(Type enumType, object value) { if (enumType == null) { throw new ArgumentNullException("enumType"); } if (value == null) { throw new ArgumentNullException("value"); } if (!enumType.IsEnum) { throw new ArgumentException("enumType is not an Enum type.", "enumType"); } value = Enum.ToObject(enumType, value); MonoEnumInfo monoEnumInfo; MonoEnumInfo.GetInfo(enumType, out monoEnumInfo); int num = Enum.FindPosition(value, monoEnumInfo.values); return (num < 0) ? null : monoEnumInfo.names[num]; } /// Returns an indication whether a constant with a specified value exists in a specified enumeration. /// true if a constant in has a value equal to ; otherwise, false. /// An enumeration type. /// The value or name of a constant in . /// /// or is null. /// /// is not an Enum.-or- The type of is an enumeration, but it is not an enumeration of type .-or- The type of is not an underlying type of . /// /// is not type , , , , , , , or , or . /// 1 // Token: 0x060003CF RID: 975 RVA: 0x0000EC70 File Offset: 0x0000CE70 [ComVisible(true)] public static bool IsDefined(Type enumType, object value) { if (enumType == null) { throw new ArgumentNullException("enumType"); } if (value == null) { throw new ArgumentNullException("value"); } if (!enumType.IsEnum) { throw new ArgumentException("enumType is not an Enum type.", "enumType"); } MonoEnumInfo monoEnumInfo; MonoEnumInfo.GetInfo(enumType, out monoEnumInfo); Type type = value.GetType(); if (type == typeof(string)) { return ((IList)monoEnumInfo.names).Contains(value); } if (type == monoEnumInfo.utype || type == enumType) { value = Enum.ToObject(enumType, value); MonoEnumInfo.GetInfo(enumType, out monoEnumInfo); return Enum.FindPosition(value, monoEnumInfo.values) >= 0; } throw new ArgumentException("The value parameter is not the correct type.It must be type String or the same type as the underlying typeof the Enum."); } // Token: 0x060003D0 RID: 976 [MethodImpl(MethodImplOptions.InternalCall)] private static extern Type get_underlying_type(Type enumType); /// Returns the underlying type of the specified enumeration. /// The underlying of . /// An enumeration type. /// /// is null. /// /// is not an . /// 1 // Token: 0x060003D1 RID: 977 RVA: 0x0000ED2C File Offset: 0x0000CF2C [ComVisible(true)] public static Type GetUnderlyingType(Type enumType) { if (enumType == null) { throw new ArgumentNullException("enumType"); } if (!enumType.IsEnum) { throw new ArgumentException("enumType is not an Enum type.", "enumType"); } return Enum.get_underlying_type(enumType); } /// Converts the string representation of the name or numeric value of one or more enumerated constants to an equivalent enumerated object. /// An object of type whose value is represented by . /// The of the enumeration. /// A string containing the name or value to convert. /// /// or is null. /// /// is not an .-or- is either an empty string or only contains white space.-or- is a name, but not one of the named constants defined for the enumeration. /// /// is outside the range of the underlying type of . /// 1 // Token: 0x060003D2 RID: 978 RVA: 0x0000ED6C File Offset: 0x0000CF6C [ComVisible(true)] public static object Parse(Type enumType, string value) { return Enum.Parse(enumType, value, false); } // Token: 0x060003D3 RID: 979 RVA: 0x0000ED78 File Offset: 0x0000CF78 private static int FindName(Hashtable name_hash, string[] names, string name, bool ignoreCase) { if (!ignoreCase) { if (name_hash != null) { object obj = name_hash[name]; if (obj != null) { return (int)obj; } } else { for (int i = 0; i < names.Length; i++) { if (name == names[i]) { return i; } } } } else { for (int j = 0; j < names.Length; j++) { if (string.Compare(name, names[j], ignoreCase, CultureInfo.InvariantCulture) == 0) { return j; } } } return -1; } // Token: 0x060003D4 RID: 980 RVA: 0x0000EE00 File Offset: 0x0000D000 private static ulong GetValue(object value, TypeCode typeCode) { switch (typeCode) { case TypeCode.SByte: return (ulong)((byte)((sbyte)value)); case TypeCode.Byte: return (ulong)((byte)value); case TypeCode.Int16: return (ulong)((ushort)((short)value)); case TypeCode.UInt16: return (ulong)((ushort)value); case TypeCode.Int32: return (ulong)((int)value); case TypeCode.UInt32: return (ulong)((uint)value); case TypeCode.Int64: return (ulong)((long)value); case TypeCode.UInt64: return (ulong)value; default: throw new ArgumentException("typeCode is not a valid type code for an Enum"); } } /// Converts the string representation of the name or numeric value of one or more enumerated constants to an equivalent enumerated object. A parameter specifies whether the operation is case-sensitive. /// An object of type whose value is represented by . /// The of the enumeration. /// A string containing the name or value to convert. /// If true, ignore case; otherwise, regard case. /// /// or is null. /// /// is not an .-or- is either an empty string ("") or only contains white space.-or- is a name, but not one of the named constants defined for the enumeration. /// /// is outside the range of the underlying type of . /// 1 // Token: 0x060003D5 RID: 981 RVA: 0x0000EE88 File Offset: 0x0000D088 [ComVisible(true)] public static object Parse(Type enumType, string value, bool ignoreCase) { if (enumType == null) { throw new ArgumentNullException("enumType"); } if (value == null) { throw new ArgumentNullException("value"); } if (!enumType.IsEnum) { throw new ArgumentException("enumType is not an Enum type.", "enumType"); } value = value.Trim(); if (value.Length == 0) { throw new ArgumentException("An empty string is not considered a valid value."); } MonoEnumInfo monoEnumInfo; MonoEnumInfo.GetInfo(enumType, out monoEnumInfo); int num = Enum.FindName(monoEnumInfo.name_hash, monoEnumInfo.names, value, ignoreCase); if (num >= 0) { return monoEnumInfo.values.GetValue(num); } TypeCode typeCode = ((Enum)monoEnumInfo.values.GetValue(0)).GetTypeCode(); if (value.IndexOf(',') != -1) { string[] array = value.Split(Enum.split_char); ulong num2 = 0UL; for (int i = 0; i < array.Length; i++) { num = Enum.FindName(monoEnumInfo.name_hash, monoEnumInfo.names, array[i].Trim(), ignoreCase); if (num < 0) { throw new ArgumentException("The requested value was not found."); } num2 |= Enum.GetValue(monoEnumInfo.values.GetValue(num), typeCode); } return Enum.ToObject(enumType, num2); } switch (typeCode) { case TypeCode.SByte: { sbyte b; if (sbyte.TryParse(value, out b)) { return Enum.ToObject(enumType, b); } break; } case TypeCode.Byte: { byte b2; if (byte.TryParse(value, out b2)) { return Enum.ToObject(enumType, b2); } break; } case TypeCode.Int16: { short num3; if (short.TryParse(value, out num3)) { return Enum.ToObject(enumType, num3); } break; } case TypeCode.UInt16: { ushort num4; if (ushort.TryParse(value, out num4)) { return Enum.ToObject(enumType, num4); } break; } case TypeCode.Int32: { int num5; if (int.TryParse(value, out num5)) { return Enum.ToObject(enumType, num5); } break; } case TypeCode.UInt32: { uint num6; if (uint.TryParse(value, out num6)) { return Enum.ToObject(enumType, num6); } break; } case TypeCode.Int64: { long num7; if (long.TryParse(value, out num7)) { return Enum.ToObject(enumType, num7); } break; } case TypeCode.UInt64: { ulong num8; if (ulong.TryParse(value, out num8)) { return Enum.ToObject(enumType, num8); } break; } } throw new ArgumentException(string.Format("The requested value '{0}' was not found.", value)); } // Token: 0x060003D6 RID: 982 [MethodImpl(MethodImplOptions.InternalCall)] private extern int compare_value_to(object other); /// Compares this instance to a specified object and returns an indication of their relative values. /// A signed number indicating the relative values of this instance and .Return Value Description Less than zero The value of this instance is less than the value of . Zero The value of this instance is equal to the value of . Greater than zero The value of this instance is greater than the value of .-or- is null. /// An object to compare, or null. /// /// and this instance are not the same type. /// This instance is not type , , , , , , , or . /// This instance is null. /// 2 // Token: 0x060003D7 RID: 983 RVA: 0x0000F0E0 File Offset: 0x0000D2E0 public int CompareTo(object target) { if (target == null) { return 1; } Type type = base.GetType(); if (target.GetType() != type) { throw new ArgumentException(string.Format("Object must be the same type as the enum. The type passed in was {0}; the enum type was {1}.", target.GetType(), type)); } return this.compare_value_to(target); } /// Converts the value of this instance to its equivalent string representation. /// The string representation of the value of this instance. /// 2 // Token: 0x060003D8 RID: 984 RVA: 0x0000F128 File Offset: 0x0000D328 public override string ToString() { return this.ToString("G"); } /// This method overload is obsolete; use . /// The string representation of the value of this instance. /// (obsolete) /// 2 // Token: 0x060003D9 RID: 985 RVA: 0x0000F138 File Offset: 0x0000D338 [Obsolete("Provider is ignored, just use ToString")] public string ToString(IFormatProvider provider) { return this.ToString("G", provider); } /// Converts the value of this instance to its equivalent string representation using the specified format. /// The string representation of the value of this instance as specified by . /// A format string. /// /// contains an invalid specification. /// /// equals "X", but the enumeration type is unknown. /// 2 // Token: 0x060003DA RID: 986 RVA: 0x0000F148 File Offset: 0x0000D348 public string ToString(string format) { if (format == string.Empty || format == null) { format = "G"; } return Enum.Format(base.GetType(), this.Value, format); } /// This method overload is obsolete; use . /// The string representation of the value of this instance as specified by . /// A format specification. /// (obsolete) /// /// does not contain a valid format specification. /// /// equals "X", but the enumeration type is unknown. /// 2 // Token: 0x060003DB RID: 987 RVA: 0x0000F184 File Offset: 0x0000D384 [Obsolete("Provider is ignored, just use ToString")] public string ToString(string format, IFormatProvider provider) { if (format == string.Empty || format == null) { format = "G"; } return Enum.Format(base.GetType(), this.Value, format); } /// Returns an instance of the specified enumeration type set to the specified 8-bit unsigned integer value. /// An instance of the enumeration set to . /// The enumeration for which to create a value. /// The value to set. /// /// is null. /// /// is not an . /// 1 // Token: 0x060003DC RID: 988 RVA: 0x0000F1C0 File Offset: 0x0000D3C0 [ComVisible(true)] public static object ToObject(Type enumType, byte value) { return Enum.ToObject(enumType, value); } /// Returns an instance of the specified enumeration type set to the specified 16-bit signed integer value. /// An instance of the enumeration set to . /// The enumeration for which to create a value. /// The value to set. /// /// is null. /// /// is not an . /// 1 // Token: 0x060003DD RID: 989 RVA: 0x0000F1D0 File Offset: 0x0000D3D0 [ComVisible(true)] public static object ToObject(Type enumType, short value) { return Enum.ToObject(enumType, value); } /// Returns an instance of the specified enumeration type set to the specified 32-bit signed integer value. /// An instance of the enumeration set to . /// The enumeration for which to create a value. /// The value to set. /// /// is null. /// /// is not an . /// 1 // Token: 0x060003DE RID: 990 RVA: 0x0000F1E0 File Offset: 0x0000D3E0 [ComVisible(true)] public static object ToObject(Type enumType, int value) { return Enum.ToObject(enumType, value); } /// Returns an instance of the specified enumeration type set to the specified 64-bit signed integer value. /// An instance of the enumeration set to . /// The enumeration for which to create a value. /// The value to set. /// /// is null. /// /// is not an . /// 1 // Token: 0x060003DF RID: 991 RVA: 0x0000F1F0 File Offset: 0x0000D3F0 [ComVisible(true)] public static object ToObject(Type enumType, long value) { return Enum.ToObject(enumType, value); } /// Returns an instance of the specified enumeration set to the specified value. /// An enumeration object whose value is . /// An enumeration. /// The value. /// /// is null. /// /// is not an .-or- is not type , , , , , , , or . /// 1 // Token: 0x060003E0 RID: 992 [ComVisible(true)] [MethodImpl(MethodImplOptions.InternalCall)] public static extern object ToObject(Type enumType, object value); /// Returns an instance of the specified enumeration type set to the specified 8-bit signed integer value. /// An instance of the enumeration set to . /// The enumeration for which to create a value. /// The value to set. /// /// is null. /// /// is not an . /// 1 // Token: 0x060003E1 RID: 993 RVA: 0x0000F200 File Offset: 0x0000D400 [ComVisible(true)] [CLSCompliant(false)] public static object ToObject(Type enumType, sbyte value) { return Enum.ToObject(enumType, value); } /// Returns an instance of the specified enumeration type set to the specified 16-bit unsigned integer value. /// An instance of the enumeration set to . /// The enumeration for which to create a value. /// The value to set. /// /// is null. /// /// is not an . /// 1 // Token: 0x060003E2 RID: 994 RVA: 0x0000F210 File Offset: 0x0000D410 [ComVisible(true)] [CLSCompliant(false)] public static object ToObject(Type enumType, ushort value) { return Enum.ToObject(enumType, value); } /// Returns an instance of the specified enumeration type set to the specified 32-bit unsigned integer value. /// An instance of the enumeration set to . /// The enumeration for which to create a value. /// The value to set. /// /// is null. /// /// is not an . /// 1 // Token: 0x060003E3 RID: 995 RVA: 0x0000F220 File Offset: 0x0000D420 [ComVisible(true)] [CLSCompliant(false)] public static object ToObject(Type enumType, uint value) { return Enum.ToObject(enumType, value); } /// Returns an instance of the specified enumeration type set to the specified 64-bit unsigned integer value. /// An instance of the enumeration set to . /// The enumeration for which to create a value. /// The value to set. /// /// is null. /// /// is not an . /// 1 // Token: 0x060003E4 RID: 996 RVA: 0x0000F230 File Offset: 0x0000D430 [ComVisible(true)] [CLSCompliant(false)] public static object ToObject(Type enumType, ulong value) { return Enum.ToObject(enumType, value); } /// Returns a value indicating whether this instance is equal to a specified object. /// true if is an with the same underlying type and value as this instance; otherwise, false. /// An object to compare with this instance, or null. /// 2 // Token: 0x060003E5 RID: 997 RVA: 0x0000F240 File Offset: 0x0000D440 public override bool Equals(object obj) { return ValueType.DefaultEquals(this, obj); } // Token: 0x060003E6 RID: 998 [MethodImpl(MethodImplOptions.InternalCall)] private extern int get_hashcode(); /// Returns the hash code for the value of this instance. /// A 32-bit signed integer hash code. /// 2 // Token: 0x060003E7 RID: 999 RVA: 0x0000F24C File Offset: 0x0000D44C public override int GetHashCode() { return this.get_hashcode(); } // Token: 0x060003E8 RID: 1000 RVA: 0x0000F254 File Offset: 0x0000D454 private static string FormatSpecifier_X(Type enumType, object value, bool upper) { switch (Type.GetTypeCode(enumType)) { case TypeCode.SByte: return ((sbyte)value).ToString((!upper) ? "x2" : "X2"); case TypeCode.Byte: return ((byte)value).ToString((!upper) ? "x2" : "X2"); case TypeCode.Int16: return ((short)value).ToString((!upper) ? "x4" : "X4"); case TypeCode.UInt16: return ((ushort)value).ToString((!upper) ? "x4" : "X4"); case TypeCode.Int32: return ((int)value).ToString((!upper) ? "x8" : "X8"); case TypeCode.UInt32: return ((uint)value).ToString((!upper) ? "x8" : "X8"); case TypeCode.Int64: return ((long)value).ToString((!upper) ? "x16" : "X16"); case TypeCode.UInt64: return ((ulong)value).ToString((!upper) ? "x16" : "X16"); default: throw new Exception("Invalid type code for enumeration."); } } // Token: 0x060003E9 RID: 1001 RVA: 0x0000F3C4 File Offset: 0x0000D5C4 private static string FormatFlags(Type enumType, object value) { string text = string.Empty; MonoEnumInfo monoEnumInfo; MonoEnumInfo.GetInfo(enumType, out monoEnumInfo); string text2 = value.ToString(); if (text2 == "0") { text = Enum.GetName(enumType, value); if (text == null) { text = text2; } return text; } switch (((Enum)monoEnumInfo.values.GetValue(0)).GetTypeCode()) { case TypeCode.SByte: { sbyte b = (sbyte)value; for (int i = monoEnumInfo.values.Length - 1; i >= 0; i--) { sbyte b2 = (sbyte)monoEnumInfo.values.GetValue(i); if ((int)b2 != 0) { if (((int)b & (int)b2) == (int)b2) { text = monoEnumInfo.names[i] + ((!(text == string.Empty)) ? ", " : string.Empty) + text; b = (sbyte)((int)b - (int)b2); } } } if ((int)b != 0) { return text2; } break; } case TypeCode.Byte: { byte b3 = (byte)value; for (int j = monoEnumInfo.values.Length - 1; j >= 0; j--) { byte b4 = (byte)monoEnumInfo.values.GetValue(j); if (b4 != 0) { if ((b3 & b4) == b4) { text = monoEnumInfo.names[j] + ((!(text == string.Empty)) ? ", " : string.Empty) + text; b3 -= b4; } } } if (b3 != 0) { return text2; } break; } case TypeCode.Int16: { short num = (short)value; for (int k = monoEnumInfo.values.Length - 1; k >= 0; k--) { short num2 = (short)monoEnumInfo.values.GetValue(k); if (num2 != 0) { if ((num & num2) == num2) { text = monoEnumInfo.names[k] + ((!(text == string.Empty)) ? ", " : string.Empty) + text; num -= num2; } } } if (num != 0) { return text2; } break; } case TypeCode.UInt16: { ushort num3 = (ushort)value; for (int l = monoEnumInfo.values.Length - 1; l >= 0; l--) { ushort num4 = (ushort)monoEnumInfo.values.GetValue(l); if (num4 != 0) { if ((num3 & num4) == num4) { text = monoEnumInfo.names[l] + ((!(text == string.Empty)) ? ", " : string.Empty) + text; num3 -= num4; } } } if (num3 != 0) { return text2; } break; } case TypeCode.Int32: { int num5 = (int)value; for (int m = monoEnumInfo.values.Length - 1; m >= 0; m--) { int num6 = (int)monoEnumInfo.values.GetValue(m); if (num6 != 0) { if ((num5 & num6) == num6) { text = monoEnumInfo.names[m] + ((!(text == string.Empty)) ? ", " : string.Empty) + text; num5 -= num6; } } } if (num5 != 0) { return text2; } break; } case TypeCode.UInt32: { uint num7 = (uint)value; for (int n = monoEnumInfo.values.Length - 1; n >= 0; n--) { uint num8 = (uint)monoEnumInfo.values.GetValue(n); if (num8 != 0U) { if ((num7 & num8) == num8) { text = monoEnumInfo.names[n] + ((!(text == string.Empty)) ? ", " : string.Empty) + text; num7 -= num8; } } } if (num7 != 0U) { return text2; } break; } case TypeCode.Int64: { long num9 = (long)value; for (int num10 = monoEnumInfo.values.Length - 1; num10 >= 0; num10--) { long num11 = (long)monoEnumInfo.values.GetValue(num10); if (num11 != 0L) { if ((num9 & num11) == num11) { text = monoEnumInfo.names[num10] + ((!(text == string.Empty)) ? ", " : string.Empty) + text; num9 -= num11; } } } if (num9 != 0L) { return text2; } break; } case TypeCode.UInt64: { ulong num12 = (ulong)value; for (int num13 = monoEnumInfo.values.Length - 1; num13 >= 0; num13--) { ulong num14 = (ulong)monoEnumInfo.values.GetValue(num13); if (num14 != 0UL) { if ((num12 & num14) == num14) { text = monoEnumInfo.names[num13] + ((!(text == string.Empty)) ? ", " : string.Empty) + text; num12 -= num14; } } } if (num12 != 0UL) { return text2; } break; } } if (text == string.Empty) { return text2; } return text; } /// Converts the specified value of a specified enumerated type to its equivalent string representation according to the specified format. /// A string representation of . /// The enumeration type of the value to convert. /// The value to convert. /// The output format to use. /// The , , or parameter is null. /// The parameter is not an type.-or- The is from an enumeration that differs in type from .-or- The type of is not an underlying type of . /// The parameter contains an invalid value. /// /// equals "X", but the enumeration type is unknown. /// 1 // Token: 0x060003EA RID: 1002 RVA: 0x0000F950 File Offset: 0x0000DB50 [ComVisible(true)] public static string Format(Type enumType, object value, string format) { if (enumType == null) { throw new ArgumentNullException("enumType"); } if (value == null) { throw new ArgumentNullException("value"); } if (format == null) { throw new ArgumentNullException("format"); } if (!enumType.IsEnum) { throw new ArgumentException("enumType is not an Enum type.", "enumType"); } Type type = value.GetType(); Type underlyingType = Enum.GetUnderlyingType(enumType); if (type.IsEnum) { if (type != enumType) { throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Object must be the same type as the enum. The type passed in was {0}; the enum type was {1}.", new object[] { type.FullName, enumType.FullName })); } } else if (type != underlyingType) { throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Enum underlying type and the object must be the same type or object. Type passed in was {0}; the enum underlying type was {1}.", new object[] { type.FullName, underlyingType.FullName })); } if (format.Length != 1) { throw new FormatException("Format String can be only \"G\",\"g\",\"X\",\"x\",\"F\",\"f\",\"D\" or \"d\"."); } char c = format[0]; string text; if (c == 'G' || c == 'g') { if (!enumType.IsDefined(typeof(FlagsAttribute), false)) { text = Enum.GetName(enumType, value); if (text == null) { text = value.ToString(); } return text; } c = 'f'; } if (c == 'f' || c == 'F') { return Enum.FormatFlags(enumType, value); } text = string.Empty; char c2 = c; if (c2 != 'D') { if (c2 == 'X') { return Enum.FormatSpecifier_X(enumType, value, true); } if (c2 != 'd') { if (c2 != 'x') { throw new FormatException("Format String can be only \"G\",\"g\",\"X\",\"x\",\"F\",\"f\",\"D\" or \"d\"."); } return Enum.FormatSpecifier_X(enumType, value, false); } } if (underlyingType == typeof(ulong)) { text = Convert.ToUInt64(value).ToString(); } else { text = Convert.ToInt64(value).ToString(); } return text; } // Token: 0x04000065 RID: 101 private static char[] split_char = new char[] { ',' }; } }