samedi 4 mars 2017

How to get delegate MethodInfo and Target via reflection?

I have a delegate as follows:

public delegate TestResult TestCase(byte[] input);

... and building a custom Visitor-type implementation to inspect the delegate. I have multiple delegate implementations that aggregate TestCases. For example:

public static TestCase Or(this TestCase tc1, TestCase tc2) {
    return tkn => {
        var res = tc1(tkn);
        if (res.Pass) {
            return res;
        }

        return tc2(tkn);
    };
}

While debugging the Or method above I can see that the returned TestCase now has a method of <Or>() and the target property has tc1 and tc2. I am trying to figure out exactly what reflection I need to perform to get the following as portrayed in the image:
enter image description here

I've been able to get Type.GetMethod("Invoke") method info. Specifically, though, how do I get the Target information?





Aucun commentaire:

Enregistrer un commentaire