BuildFeed/Views/shared/DisplayTemplates/Enumeration.cshtml

24 lines
559 B
Plaintext
Raw Normal View History

2014-10-11 06:57:02 +08:00
@using System.ComponentModel.DataAnnotations
@model Enum
2014-10-11 06:57:02 +08:00
@{
Func<object, string> GetDisplayName = o =>
{
var result = null as string;
var display = o.GetType()
.GetMember(o.ToString()).First()
.GetCustomAttributes(false)
.OfType<DisplayAttribute>()
.LastOrDefault();
if (display != null)
{
result = display.GetName();
}
return result ?? o.ToString();
};
}
@GetDisplayName(ViewData.Model)