Click here to Skip to main content
15,920,383 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The title Maybe make you confused.ok!the following I will show an example:
at first,i save a xml file to test like this;
<behaviorInfo>
<name>tiger</name>
<actionname>play</actionname>
</behaviorInfo>

I want my application can invoke the method named "play" which I have defined in my source file by reading the xml file.Of course,I can change the "actionname" child element,maybe "eat",the application can change its own behavior not need to be recompiled.

thank you very much!
Posted
Updated 19-Dec-09 23:21pm
v6

1 solution

Well, given that your application should only have method names that are known to you at compile time, you should be able to parse your XML and use a switch statement to do this. However, if you want it to magically work with any methods that you add in future, then you need to write code that causes your code to call itself using reflection.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900