1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-16 07:52:36 +01:00
Radarr/NzbDrone.Web/Helpers/DescriptionExtension.cs
Mark McDowall 0b586de226 Added misnamed provider, PLINQ speeds it up, but still to slow for use, paging helps, but isn't consistent.
A bunch of files changed removing System.Linq, thanks Resharper :(
2011-09-03 20:05:44 -07:00

27 lines
868 B
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq.Expressions;
using System.Web;
using System.Web.Mvc;
namespace NzbDrone.Web.Helpers
{
public static class DescriptionExtension
{
public static MvcHtmlString DescriptionFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> 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);
}
}
}