vendredi 17 juillet 2015

Create Function Via Refection To Call Another Reflected Method

Use case: I have a bunch of service reference's in my solution.

Ultimately I want to dynamically generate a wpf window that asks for all the parameters of each method defined by the Reference.cs files generated by the wsdl, call the method and spit out the results.

I created a class Caller<T>. For each service reference, it inherits this class, defines the target url, and the Caller class creates the bindings and executes the action on the channel. It defines a method: TResult Run<TResult>(Func<T, TResult> function)

So basically wpf window.

  • select service (found by reflection)
  • select method (for service found by reflection)
  • dynamically generate inputs for each parameter of method (for selected method)

So I'm on step 3 Given I have used reflection to create an instance of the implemented Caller for T. I want to actually call the method from step 2. So I need to generate a function that executes the methodinfo from 2, passing the params array i generated in step 3.





Aucun commentaire:

Enregistrer un commentaire