private static void ParseFunction(object o, ZXPProxy zpp, string s, List<DIndices> ld, ref int li)
{
// Check If A Key Is Available
string key = GetKeyString(s, ld, li);
if(string.IsNullOrWhiteSpace(key))
return;
// Find The Method That Matches To This Key
ZXPFunc func;
MethodInfo method = null;
if(!zpp.FuncsDict.TryGetValue(key, out func)) return;
method = func.Method;
// Check For Simple Invoke
ParameterInfo[] paramInfo = method.GetParameters();
if(paramInfo.Length < 1 || paramInfo == null) {
method.Invoke(o, null);
return;
}
// Parse Parameters
string sArgs = s.Substring(ld[li].Start, ld[li].Length);
object[] args = new object[paramInfo.Length];
var nl = Delimiter.Delimit(sArgs, DelimitType.Angled | DelimitType.Curly);
// Check Number Of Arguments
int ca = 0;
foreach(var ndi in nl) {
if(ndi.Type == DelimitType.Curly) ca++;
}
if(ca != args.Length) return;
// Create Parameters
int ai = 0, pi = 0;
for(; pi < args.Length; ) {
if(nl[ai].Type == DelimitType.Angled) {
if(ai >= nl.Count - 1 || nl[ai + 1].Type != DelimitType.Curly) {
ai++;
continue;
}
// Get The Argument Type
string atValue = sArgs.Substring(nl[ai].Start, nl[ai].Length);
if(string.IsNullOrWhiteSpace(atValue))
break;
Type aType = GetTypeFromString(atValue);
if(aType == null)
break;
// Get The Argument
string sValue = sArgs.Substring(nl[ai + 1].Start, nl[ai + 1].Length);
IZXPConverter conv;
ZXParser.GetConverter(aType, out conv);
if(ReadValue(sValue, conv, aType, out args[pi])) {
pi++;
}
ai += 2;
}
else {
// Simple Parse
Type aType = paramInfo[pi].ParameterType;
string sValue = sArgs.Substring(nl[ai].Start, nl[ai].Length);
IZXPConverter conv;
ZXParser.GetConverter(aType, out conv);
if(ReadValue(sValue, conv, aType, out args[pi])) {
pi++;
}
ai++;
}
}
// Check That All Arguments Are OK
if(pi == args.Length) {
method.Invoke(o, args);
}
}