This class creates a generic method delegate from a MethodInfo signature converting the method call into a LateBoundMethod delegate call. Using this class allows making repeated calls very quickly.
Note: this class will be very inefficient for individual dynamic method calls - compilation of the expression is very expensive up front, so using this delegate factory makes sense only if you re-use the dynamicly loaded method repeatedly.
Entirely based on Nate Kohari's blog post: http://kohari.org/2009/03/06/fast-late-bound-invocation-with-expression-trees/
Westwind.Utilities.DelegateFactory
public static class DelegateFactory : object
Class Members
Member | Description | |
---|---|---|
Create |
Creates a LateBoundMethod delegate from a MethodInfo structure Basically creates a dynamic delegate instance (code) on the fly. public static LateBoundMethod Create(MethodInfo method) public static LateBoundMethod Create(Type type, string methodName, Type[] parameterTypes) |
Requirements
Namespace: Westwind.UtilitiesAssembly: westwind.utilities.dll
© West Wind Technologies, 1996-2024 • Updated: 06/29/24
Comment or report problem with topic