Created
February 7, 2019 08:29
-
-
Save MirzaMerdovic/a4edc57219a7634479f3ae5482754dfc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static TDelegate BuildHandler<TDelegate>(TServiceImpl instance, string methodName) | |
{ | |
MethodInfo method = instance.GetType().GetMethod(methodName); | |
IEnumerable<ParameterExpression> parameters = method.GetParameters().Select(x => Expression.Parameter(x.ParameterType)).ToList(); | |
var call = Expression.Call(Expression.Constant(instance), method, parameters); | |
var func = Expression.Lambda<TDelegate>(call, false, parameters).Compile(); | |
return func; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment