We're using DynamicProxy in a project. I've created an interceptor for a few methods.
I know that it's possible to get the method arguments inside of a Castle.DynamicProxy.IInterceptor object.
Can an interceptor change the value of the arguments passed to a method, before calling invocation.Proceed()?
Yes - yes, it can.
In this case, one can use Reflection on the IInvocation.Method property to get the method parameters; the method arguments are attached directly to the invocation. Although the arguments property is a readonly value (no public setter) it's of type object[] - so its properties are writable.
Thus, an interceptor can change argument values by writing to the arguments object, using the correct index corresponding to the method parameter position.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With