コード例 #1
0
        public static HtmlString CustomerEnumDisplayNameFor(this CustomerType item)
        {
            var type   = item.GetType();
            var member = type.GetMember(item.ToString());
            DisplayAttribute displayName = (DisplayAttribute)member[0].GetCustomAttributes(typeof(DisplayAttribute), false).FirstOrDefault();

            if (displayName != null)
            {
                return(new HtmlString(displayName.Name));
            }

            return(new HtmlString(item.ToString()));
        }