コード例 #1
0
        /// <summary>
        /// Item type enum
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static string GetItemNameFromEnum(this ItemTypeEnum type)
        {
            try
            {
                var field      = type.GetType().GetField(type.ToString());
                var customAttr = field.GetCustomAttributes(typeof(DescriptionAttribute), false);

                if (customAttr.Length > 0)
                {
                    return((customAttr[0] as DescriptionAttribute).Description);
                }

                return(type.ToString());
            }
            catch (Exception)
            {
                throw;
            }
        }