BananaHook.ReflectionDetourNotifier.GenerateInterceptor C# (CSharp) Method

GenerateInterceptor() private method

private GenerateInterceptor ( Delegate targetDelegate ) : Delegate
targetDelegate System.Delegate
return System.Delegate
        private Delegate GenerateInterceptor(Delegate targetDelegate)
        {
            Type delegateType = targetDelegate.GetType();
            MethodInfo mi = delegateType.GetMethod("Invoke");
            ParameterExpression[] parameters = (from p in mi.GetParameters()
                                                select Expression.Parameter(p.ParameterType, p.Name)).ToArray();

            var builder = new InterceptorFuncBuilder(this);
            return builder.CreateLambdaBody(parameters, delegateType, mi);
        }