mirror of
https://github.com/Sonarr/Sonarr
synced 2024-12-26 01:37:07 +00:00
0b586de226
A bunch of files changed removing System.Linq, thanks Resharper :(
26 lines
No EOL
765 B
C#
26 lines
No EOL
765 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 ValueExtension
|
|
{
|
|
public static object ValueFor<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 model = html.ViewData.Model;
|
|
var value = model.GetType().GetProperty(name).GetValue(model, null);
|
|
|
|
return value;
|
|
}
|
|
}
|
|
} |