Kettenmethodekallexpression mit ExpressionC#

Ein Treffpunkt für C#-Programmierer
Guest
 Kettenmethodekallexpression mit Expression

Post by Guest »

Ich versuche, eine methodCallexpression mit einem Lambda -Ausdruck zusammenzustellen. Grundsätzlich möchte ich, dass eine Methode jedes Mal aufgerufen wird, wenn der Lambda -Ausdruck aufgerufen wird. />

Code: Select all

public Func Get(Object obj,  Action action = null)
{
Expression lambda = GetLambdaExpression(obj);
var parameterValue = action.Method.GetParameters().Single();
var callback = Expression.Call(Expression.Constant(action.Target), action.Method, Expression.Constant(parameterValue));
return lambda.Compile();

}
Ich muss irgendwie die Lambda und den Action -Rückruf kombinieren und in einen Func kompilieren. So etwas: < /p>

Code: Select all

obj => { action(obj); return lambda(obj); }

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post