Using spread of strings to call multiple functions - reflection

hi all,

I have a mobile device controlling the program. Commands come within a json. Now this looks like it could be solved in a nicer way:

basically I want to create a spread of my xpath and its corresponding function name.
then set all values in one loop. I remember some gamma functionality which does exactly this, but cant find it.

probably lost in element

hm… you should at least be able to get rid of the TryParse nodes (those are already inside the adaptive XPathGetValue). other than that, since every Set… is different i don’t see how you’d slim that down.

Looks like a good example for using delegates…

1 Like

ha! I did save it somewhere. As I understand the process node on top holds the methods, and I can call them by name, and send overloads into them.

CallByName.vl (17.8 KB)

Could I use this technique to clean up my code?

ah yes, Reflection. that should work.

but typically you don’t use reflection to “clean up” your code but rather to do things that you couldn’t do otherwise, like calling functions on objects you only get to know at runtime or similar… or the number of functions to call (in your example) changes from call to call…

if it is only about cleanup, i’d not recommend using it.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.