I have got a variable which contains function hierarchy like:
string str= "fun1(fun2(),fun3(fun4(fun5(34,33,'aa'),'value',fun6()))"
// this hierarchy is coming as a string from database
I have imported System.reflection and used invoke method to invoke it, but it's only working if I have a only one function fun1
.
With above function hierarchy it's taking complete expression as a one function name.
I am using this below code to invoke my function hierarchy:
public static string InvokeStringMethod(string typeName, string methodName)
{
// Get the Type for the class
Type calledType = Type.GetType(typeName);
// Invoke the method itself. The string returned by the method winds up in s
String s = (String)calledType.InvokeMember(
methodName,
BindingFlags.InvokeMethod | BindingFlags.Public |
BindingFlags.Static,
null,
null,
null);
// Return the string that was returned by the called method.
return s;
}
Reference: http://www.codeproject.com/KB/cs/CallMethodNameInString.aspx
Please tell me what should I do?