Esempio n. 1
0
        public static ICollection GetEnumNames(Type EnumType)
        {
            EnumDataCache dc;

            if (!EnumCache.TryGetValue(EnumType, out dc))
            {
                dc = new EnumDataCache(EnumType);
                EnumCache.Add(EnumType, dc);
            }
            return(dc.GetNames());
        }
Esempio n. 2
0
        public static object GetEnumValue(Type EnumType, object DataName)
        {
            EnumDataCache dc;

            if (!EnumCache.TryGetValue(EnumType, out dc))
            {
                dc = new EnumDataCache(EnumType);
                EnumCache.Add(EnumType, dc);
            }
            if (DataName.GetType() == typeof(string))
            {
                return(dc.GetValue((string)DataName));
            }
            else
            {
                return(DataName);
            }
        }
Esempio n. 3
0
        public static string GetEnumName(Type EnumType, object Value)
        {
            if (EnumType == typeof(string))
            {
                return((string)Value);
            }

            EnumDataCache dc;

            if (!EnumCache.TryGetValue(EnumType, out dc))
            {
                dc = new EnumDataCache(EnumType);
                EnumCache.Add(EnumType, dc);
            }
            if (Value.GetType() == typeof(int))
            {
                Value = Enum.ToObject(EnumType, Value);
            }
            return(dc.GetName(Value));
        }