BuildFeed/Views/shared/DisplayTemplates/Enumeration.cshtml
2014-10-10 23:57:02 +01:00

25 lines
585 B
Plaintext

@using System.ComponentModel.DataAnnotations
@model BuildFeed.Models.TypeOfSource
@{
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)