Get Parameters from Action

How do I get the parameters passed into an Action ? The code example should highlight what I'm trying to achieve. Sorry that it's a little bit long.

class Program
{
    static void Main(string[] args)
    {
        Foo foo = new Foo();
        foo.GetParams(x => x.Bar(7, "hello"));
    }
}

class Foo
{
    public void Bar(int val, string thing) { }
}

static class Ex
{
    public static object[] GetParams<T>(this T obj, Action<T> action)
    {
        // Return new object[]{7, "hello"}
    }
}

The only options that look vaguely useful are GetInvocationList(), Method and Target. But none of them seem to contain the data I'm after (I think it's because of the way I've declared the Action). Thanks

EDIT: It's not the types I want, it's the actual values - as noted in the commented bit of code.

6
задан Albin Sunnanbo 5 December 2010 в 21:39
поделиться