public bool executeMulticall(string methodNameRoot, XmlRpcValue parms, XmlRpcValue result)
{
if (methodNameRoot != SYSTEM_MULTICALL) return false;
// There ought to be 1 parameter, an array of structs
if (parms.Length != 1 || parms[0].Type != XmlRpcValue.ValueType.TypeArray)
throw new XmlRpcException(SYSTEM_MULTICALL + ": Invalid argument (expected an array)");
int nc = parms[0].Length;
result.SetArray(nc);
for (int i = 0; i < nc; ++i)
{
if (!parms[0][i].hasMember(METHODNAME) ||
!parms[0][i].hasMember(PARAMS))
{
result[i].Set(FAULTCODE, -1);
result[i].Set(FAULTSTRING, SYSTEM_MULTICALL + ": Invalid argument (expected a struct with members methodName and params)");
continue;
}
string methodName = parms[0][i][METHODNAME].GetString();
XmlRpcValue methodParams = parms[0][i][PARAMS];
XmlRpcValue resultValue = new XmlRpcValue();
resultValue.SetArray(1);
try
{
if (!executeMethod(methodName, methodParams, resultValue[0]) &&
!executeMulticall(methodName, parms, resultValue[0]))
{
result[i].Set(FAULTCODE, -1);
result[i].Set(FAULTSTRING, methodName + ": unknown method name");
}
else
result[i] = resultValue;
}
catch (XmlRpcException fault)
{
result[i].Set(FAULTCODE, 0);
result[i].Set(FAULTSTRING, fault.Message);
}
}
return true;
}