CodeInject icon indicating copy to clipboard operation
CodeInject copied to clipboard

Question: How can I write a generic injection that accepts any number of parameters

Open asdf23 opened this issue 8 years ago • 0 comments

I am trying to write an injector to accept any number of parameters. By "injector" I mean the method which would be injected into another existing method. That method would look like

public static class MethodDefinitionInjector
{
    public static DumpParameter(params object[] args)
    {
        foreach(object o in args) ...
    }
}

I can only get it to work when the parameters perfectly match. I'm injecting in the following manner:

methodDefinitionToInject.InjectWith(methodDefinitionInjector, 0, null, InjectFlags.PassParametersVal, InjectDirection.Before, null, null);

Is this possible? How should I rewrite the injection?

asdf23 avatar Jul 18 '17 19:07 asdf23