Is there any way to get the argument values? I can get parameter names using invocation.Request.Method.GetParameters, but I didnโt find a way to get the actual values
for the arguments I created, a little helper that will give you the name of the argument mapped to a value that can then be converted to a dictionary.
private IEnumerable<KeyValuePair<string, object>> MapParameters(object[] arguments, ParameterInfo[] getParameters) { for (int i = 0; i < arguments.Length; i++) { yield return new KeyValuePair<string, object>(getParameters[i].Name, arguments[i]); } }
will look like this:
var mappedParameters = MapParameters(invocation.Arguments, invocation.Method.GetParameters()) .ToDictionary(x => x.Key, x => x.Value?.ToString());
Example
Method Signature: Get (int id)
use : receive (1)
output : {[id, 1]}
source share