public List<List<uint>> ProcessMutipleRops(
List<ISerializable> requestRops,
List<uint> inputObjHandles,
ref List<IDeserializable> responseRops,
ref byte[] rawData,
RopResponseType expectedRopResponseType)
{
List<uint> requestSOH = new List<uint>();
for (int i = 0; i < inputObjHandles.Count; i++)
{
requestSOH.Add(inputObjHandles[i]);
}
List<List<uint>> responseSOHs = new List<List<uint>>();
uint ret = this.RopCall(requestRops, requestSOH, ref responseRops, ref responseSOHs, ref rawData, MaxRgbOut);
if (ret != OxcRpcErrorCode.ECNone)
{
Site.Assert.AreEqual<RopResponseType>(RopResponseType.RPCError, expectedRopResponseType, "Unexpected RPC error {0} occurred.", ret);
return responseSOHs;
}
int numOfReqs = requestRops.Count;
int numOfRess = responseRops.Count;
for (int reqIndex = 0, resIndex = 0; reqIndex < numOfReqs && resIndex < numOfRess; resIndex++, reqIndex++)
{
while (requestRops[reqIndex].GetType() == typeof(RopReleaseRequest) && (reqIndex < numOfReqs - 1))
{
reqIndex++;
}
try
{
Type reqType = requestRops[reqIndex].GetType();
string resName = responseRops[resIndex].GetType().Name;
// The word "Response" takes 8 length.
string ropName = resName.Substring(0, resName.Length - 8);
Type adapterType = typeof(MS_OXCROPSAdapter);
// Call capture code using reflection mechanism
// The code followed is to construct the verify method name of capture code and then call this method through reflection.
MethodInfo method = null;
string verifyMethodName = "Verify" + ropName + "SuccessResponse";
method = adapterType.GetMethod(verifyMethodName, BindingFlags.NonPublic | BindingFlags.Instance);
if (method == null)
{
verifyMethodName = "Verify" + ropName + "FailureResponse";
method = adapterType.GetMethod(verifyMethodName, BindingFlags.NonPublic | BindingFlags.Instance);
}
if (method == null)
{
verifyMethodName = "Verify" + ropName + "Response";
method = adapterType.GetMethod(verifyMethodName, BindingFlags.NonPublic | BindingFlags.Instance);
}
if (method != null)
{
ParameterInfo[] paraInfos = method.GetParameters();
int paraNum = paraInfos.Length;
object[] paraObjects = new object[paraNum];
paraObjects[0] = responseRops[resIndex];
for (int i = 1; i < paraNum; i++)
{
FieldInfo fieldInReq = reqType.GetField(
paraInfos[i].Name,
BindingFlags.IgnoreCase
| BindingFlags.DeclaredOnly
| BindingFlags.Public
| BindingFlags.NonPublic
| BindingFlags.GetField
| BindingFlags.Instance);
if (fieldInReq == null)
{
foreach (ISerializable req in requestRops)
{
Type type = req.GetType();
fieldInReq = type.GetField(
paraInfos[i].Name,
BindingFlags.IgnoreCase
| BindingFlags.DeclaredOnly
| BindingFlags.Public
| BindingFlags.NonPublic
| BindingFlags.GetField
| BindingFlags.Instance);
if (fieldInReq != null)
{
paraObjects[i] = fieldInReq.GetValue(req);
}
}
}
else
{
paraObjects[i] = fieldInReq.GetValue(requestRops[reqIndex]);
}
}
method.Invoke(this, paraObjects);
}
}
catch (TargetInvocationException invocationEx)
{
Site.Log.Add(LogEntryKind.Debug, invocationEx.Message);
if (invocationEx.InnerException != null)
{
throw invocationEx.InnerException;
}
}
catch (NullReferenceException nullEx)
{
Site.Log.Add(LogEntryKind.Debug, nullEx.Message);
}
if (resIndex < numOfRess - 1)
{
if (responseRops[resIndex + 1].GetType() == typeof(RopNotifyResponse) || responseRops[resIndex + 1].GetType() == typeof(RopPendingResponse))
{
reqIndex--;
}
}
}
return responseSOHs;
}