diff --git a/NzbDrone.Web/Helpers/DescriptionExtension.cs b/NzbDrone.Web/Helpers/DescriptionExtension.cs new file mode 100644 index 000000000..658397e17 --- /dev/null +++ b/NzbDrone.Web/Helpers/DescriptionExtension.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Linq.Expressions; +using System.Web; +using System.Web.Mvc; + +namespace NzbDrone.Web.Helpers +{ + public static class DescriptionExtension + { + public static MvcHtmlString DescriptionFor(this HtmlHelper html, Expression> expression) + { + var memberEx = expression.Body as MemberExpression; + + if (memberEx == null) + throw new ArgumentException("Body not a member-expression."); + + string name = memberEx.Member.Name; + + var attributes = TypeDescriptor.GetProperties(typeof(TModel))[name].Attributes; + var desc = (DescriptionAttribute)attributes[typeof(DescriptionAttribute)]; + + return new MvcHtmlString(desc.Description); + } + } +} \ No newline at end of file diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj index 85cc4278e..ba5c544b6 100644 --- a/NzbDrone.Web/NzbDrone.Web.csproj +++ b/NzbDrone.Web/NzbDrone.Web.csproj @@ -224,6 +224,7 @@ Global.asax +