diff options
Diffstat (limited to 'mcs/class/corlib/System/Enum.cs')
-rw-r--r-- | mcs/class/corlib/System/Enum.cs | 196 |
1 files changed, 0 insertions, 196 deletions
diff --git a/mcs/class/corlib/System/Enum.cs b/mcs/class/corlib/System/Enum.cs deleted file mode 100644 index 0ed2648640e..00000000000 --- a/mcs/class/corlib/System/Enum.cs +++ /dev/null @@ -1,196 +0,0 @@ -// -// System.Enum.cs -// -// Author: -// Miguel de Icaza (miguel@ximian.com) -// -// (C) Ximian, Inc. http://www.ximian.com -// -// TODO: Mucho left to implement. -// - -using System.Globalization; -using System.Runtime.CompilerServices; - -namespace System { - internal struct MonoEnumInfo { - internal Type utype; - internal Array values; - internal string[] names; - - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern void get_enum_info (Type enumType, out MonoEnumInfo info); - - internal static void GetInfo (Type enumType, out MonoEnumInfo info) { - get_enum_info (enumType, out info); - Array.Sort (info.values, info.names); - } - }; - - [MonoTODO] - public abstract class Enum : ValueType, IComparable { - - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private extern object get_value (); - - public static Array GetValues (Type enumType) { - MonoEnumInfo info; - MonoEnumInfo.GetInfo (enumType, out info); - return info.values; - } - - public static string[] GetNames (Type enumType) { - MonoEnumInfo info; - MonoEnumInfo.GetInfo (enumType, out info); - return info.names; - } - - public static string GetName (Type enumType, object value) { - MonoEnumInfo info; - int i; - MonoEnumInfo.GetInfo (enumType, out info); - for (i = 0; i < info.values.Length; ++i) { - if (value.Equals (info.values.GetValue (i))) - return info.names [i]; - } - return null; - } - - public static bool IsDefined (Type enumType, object value) { - return GetName (enumType, value) != null; - } - - public static Type GetUnderlyingType (Type enumType) { - MonoEnumInfo info; - MonoEnumInfo.GetInfo (enumType, out info); - return info.utype; - } - - public static object Parse (Type enumType, string value) - { - return Parse (enumType, value, false); - } - - public static object Parse (Type enumType, string value, bool ignoreCase) - { - MonoEnumInfo info; - int i; - MonoEnumInfo.GetInfo (enumType, out info); - for (i = 0; i < info.values.Length; ++i) { - if (String.Compare (value, info.names [i], ignoreCase) == 0) - return ToObject (enumType, info.values.GetValue (i)); - } - throw new ArgumentException ("The rquested value was not found"); - } - - /// <summary> - /// Compares the enum value with another enum value of the same type. - /// </summary> - /// - /// <remarks> - /// - int IComparable.CompareTo (object obj) - { - if (obj == null) - return 1; - - object value1, value2; - - value1 = this.get_value (); - - if (obj is Enum) - value2 = ((Enum)obj).get_value(); - else - value2 = obj; - - return ((IComparable)value1).CompareTo (value2); - } - - public override string ToString () - { - return ToString ("G", null); - } - - public string ToString (IFormatProvider provider) - { - return ToString ("G", provider); - } - - public string ToString (String format) - { - return ToString (format, null); - } - - public string ToString (String format, IFormatProvider provider) - { - // fixme: consider format and provider - return GetName (this.GetType(), this.get_value ()); - } - - public static object ToObject(Type enumType, byte value) - { - return ToObject (enumType, (object)value); - } - - public static object ToObject(Type enumType, short value) - { - return ToObject (enumType, (object)value); - } - public static object ToObject(Type enumType, int value) - { - return ToObject (enumType, (object)value); - } - public static object ToObject(Type enumType, long value) - { - return ToObject (enumType, (object)value); - } - - [MethodImplAttribute(MethodImplOptions.InternalCall)] - public static extern object ToObject(Type enumType, object value); - - [CLSCompliant(false)] - public static object ToObject(Type enumType, sbyte value) - { - return ToObject (enumType, (object)value); - } - [CLSCompliant(false)] - public static object ToObject(Type enumType, ushort value) - { - return ToObject (enumType, (object)value); - } - [CLSCompliant(false)] - public static object ToObject(Type enumType, uint value) - { - return ToObject (enumType, (object)value); - } - [CLSCompliant(false)] - public static object ToObject(Type enumType, ulong value) - { - return ToObject (enumType, (object)value); - } - - public override bool Equals (object obj) - { - if (!(obj is Enum)) - return false; - - object v1 = this.get_value (); - object v2 = ((Enum)obj).get_value (); - - return v1.Equals (v2); - } - - public override int GetHashCode () - { - object v = this.get_value (); - return v.GetHashCode (); - } - - public static string Format (Type enumType, object value, string format) - { - // fixme: consider format - return GetName (enumType, value); - } - - } -} |