There is a DisplayNameFor(x=>x.Title)
helper in ASP.Net MVC.
I want to implement something similar in behavior.
I want to have a method that accepts
something like this:
Expression> GenerateAssignExpression
(Expression> getExpression,
TProperty Value)
{
var getExpressionBody = getExpression.Body as MemberExpression;
if (getExpressionBody == null)
{
throw new Exception("getExpressionBody is not MemberExpression: " +
getExpression.Body);
}
var objectParameter = (ParameterExpression)getExpression.Parameters[0];
ConstantExpression constant = Expression.Constant(Value, typeof(TProperty));
var expAssign = Expression.Assign(e.Body, constant);
return Expression.Lambda>(expAssign,
objectParameter,
valueParameter);
}