How to get arguments (i.e. parameter values) during interception?

Jan 21, 2015 at 12:13 AM
I am trying to port Unity Interception to Simple Injector Interception
In Unity, the method signature IMethodInvocation that gives direct access to the arguments.

However, when I look at the code snippet here

I see the signature is IInvocation
I can use GetConcreteMethod and GetParameters to get the parameter name, but as far as I know, I can't get the value.

If I use the VS debugger, I can see that this information is available via

and then to access the

to look at InArgs to get my array of arguments.

To be honest, I'm not that familiar with all of this, so was wondering how I could get to the arguments in my code given the above?

Jan 21, 2015 at 6:41 PM
Just add a IMethodCallMessage Message { get; } property to the IInvocation interface and you're ready to go.
Jan 21, 2015 at 8:28 PM
OK, figured it out.
I ended up add an extra property to the interface snippet, i.e.
public interface IInvocation
    object InvocationTarget { get; }
    object ReturnValue { get; set; }
    void Proceed();
    MethodBase GetConcreteMethod();
    IMethodCallMessage Message { get; set; } // added this