Search code examples
c#arraysreflectionproxy-classes

Proxying an array type


I'm writing new TFS-related tasks in the MSBuild Community Task project.

How do I proxy an array type? The CheckIn function exposed in the TFS assembly expects an array of PendingChange objects i.e.: "PendingChange[]".

Now, I've proxied the PendingChange class, but how do I get the CheckIn method?

MethodInfo getPendEditMethod = _type.GetMethod("CheckIn", new Type[] { typeof(string[]), typeof(PendingChange[]) });

This will evidently not work.

Same thing, how do I invoke the method once I've gotten a handle to it?


Solution

  • For your first question: typeof(Array) should do.
    For your second question, look at MethodInfo.Invoke.