If you used lambda instead of expressions, your current code would look like this: var serviceInstance = …; // retrieve using reflection proxy. Call(i => serviceInstance. CallMethod(parameters)) Note that the lambda takes the parameter I but doesn't use it.
I assume you want to call the method directly on I i.e. Something like this: proxy. Call(i => i.
CallMethod(parameters)) To do that, use the value of Expression.Parameter() as thisParam : var thisParam = Expression. Parameter(type, "i"); // the name is optional var call = Expression. Call(thisParam, serviceMethod, valueParams); var func = Expression.
Lambda(call, thisParam).Compile().
If you used lambda instead of expressions, your current code would look like this: var serviceInstance = …; // retrieve using reflection proxy. Call(i => serviceInstance. CallMethod(parameters)); Note that the lambda takes the parameter i, but doesn't use it.
I assume you want to call the method directly on i, i.e. Something like this: proxy. Call(i => i.
CallMethod(parameters)); To do that, use the value of Expression.Parameter() as thisParam: var thisParam = Expression. Parameter(type, "i"); // the name is optional var call = Expression. Call(thisParam, serviceMethod, valueParams); var func = Expression.
Lambda(call, thisParam).Compile().
THANK YOU! You are a code saver! The part I was missing while trying to get it to work was the last line 'Expression.
Lambda(call, thisParam'. I had always kept it as 'Expression. Lambda(call, Expression.
Parameter(type))' and that throws an error because it cannot understand what 'i' (or whatever I call the variable) is. – dlswimmer Jun 10 at 15:01 To further expand on why I couldn't just call 'proxy. Call(i => i.
CallMethod(params));', the proxy was created using reflection as well and since the interface was generic typed as well, I did not have direct access to the method. – dlswimmer Jun 10 at 15:09.
The code in the question calls the proxy, it's not the code inside it. – svick Jun 9 at 20:36.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.