I need to execute all the outgoing WCF methods' calls in one safe place. Thus, I created a function which gets Expression<Action<T>>
parameter and then executes the pointed method.
Inside this method I can get the name of the complete event which executes right after the method invocation.
I want to register to this event (by reflection probably). Note that the Complete event's args can be of any type so i'll, probably, have to use a lambda expression. Here is the function:
public void Invoke<T>(Expression<Action<T>> action) where T : class
{
var method = (MethodCallExpression)action.Body;
string methodName = method.Method.Name;
Action<T> m = action.Compile();
string eventName = methodName + "Completed";
// Here I want to register to the eventName event.
m.Invoke(obj);
}
Aucun commentaire:
Enregistrer un commentaire