/// <summary> /// Check whether the default invalid handle is needed. /// </summary> /// <param name="ropRequest">ROP request objects.</param> /// <param name="expectedRopResponseType">The expected ROP response type.</param> /// <returns>Return true if the default handle is needed in the request, otherwise return false.</returns> private bool IsInvalidInputHandleNeeded(ISerializable ropRequest, RopResponseType expectedRopResponseType) { if (!Common.IsOutputHandleInRopRequest(ropRequest) && expectedRopResponseType == RopResponseType.FailureResponse) { byte[] request = ropRequest.Serialize(); // The default handle is also needed by some cases to verify the failure response caused by an invalid input handle. // The input handle index is the third byte and its value is 1 in this test suite for this situation. byte inputHandleIndex = request[2]; if (inputHandleIndex == 1) { return(true); } } return(false); }
/// <summary> /// Method which executes single ROP. /// </summary> /// <param name="ropRequest">ROP request objects.</param> /// <param name="inputObjHandle">Server object handle in request.</param> /// <param name="response">ROP response objects.</param> /// <param name="rawData">The ROP response payload.</param> /// <param name="expectedRopResponseType">ROP response type expected.</param> /// <returns>Server objects handles in response.</returns> public List <List <uint> > ProcessSingleRop( ISerializable ropRequest, uint inputObjHandle, ref IDeserializable response, ref byte[] rawData, RopResponseType expectedRopResponseType) { uint returnValue; List <List <uint> > responseSOHs = this.ProcessSingleRopWithReturnValue(ropRequest, inputObjHandle, ref response, ref rawData, expectedRopResponseType, out returnValue); if (returnValue == 1726) { Site.Assert.AreEqual <RopResponseType>(RopResponseType.RPCError, expectedRopResponseType, "Unexpected RPC error {0} occurred.", returnValue); } return(responseSOHs); }
/// <summary> /// Method which executes single ROP with multiple server objects. /// </summary> /// <param name="ropRequest">ROP request object.</param> /// <param name="insideObjHandle">Server object handles in request.</param> /// <param name="response">ROP response object.</param> /// <param name="rawData">The ROP response payload.</param> /// <param name="expectedRopResponseType">ROP response type expected.</param> /// <returns>Server objects handles in response.</returns> private List<List<uint>> ProcessSingleRopWithMutipleServerObjects( ISerializable ropRequest, List<uint> insideObjHandle, ref IDeserializable response, ref byte[] rawData, RopResponseType expectedRopResponseType) { List<ISerializable> requestRops = new List<ISerializable> { ropRequest }; List<uint> requestSOH = new List<uint>(); for (int i = 0; i < insideObjHandle.Count; i++) { requestSOH.Add(insideObjHandle[i]); } if (Common.IsOutputHandleInRopRequest(ropRequest)) { // Add an element for server output object handle, set default value to 0xFFFFFFFF requestSOH.Add(DefaultOutputHandle); } List<IDeserializable> responseRops = new List<IDeserializable>(); List<List<uint>> responseSOHs = new List<List<uint>>(); uint ret = this.oxcropsClient.RopCall(requestRops, requestSOH, ref responseRops, ref responseSOHs, ref rawData, MaxRgbOut); this.Site.Assert.AreEqual<uint>(OxcRpcErrorCode.ECNone, ret, "ROP call should return 0 for success, actually it returns {0}", ret); if (responseRops != null) { if (responseRops.Count > 0) { response = responseRops[0]; } } else { response = null; } if (ropRequest is RopReleaseRequest) { return responseSOHs; } try { string resName = response.GetType().Name; // The word "Response" takes 8 length. string ropName = resName.Substring(0, resName.Length - 8); Type adapterType = typeof(MS_OXCPRPTAdapter); // 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. string verifyMethodName = string.Empty; if (expectedRopResponseType == RopResponseType.SuccessResponse) { verifyMethodName = "Verify" + ropName + "SuccessResponse"; } else if (expectedRopResponseType == RopResponseType.FailureResponse) { verifyMethodName = "Verify" + ropName + "FailureResponse"; } else if (expectedRopResponseType == RopResponseType.Response) { verifyMethodName = "Verify" + ropName + "Response"; } else if (expectedRopResponseType == RopResponseType.NullDestinationFailureResponse) { verifyMethodName = "Verify" + ropName + "NullDestinationFailureResponse"; } else if (expectedRopResponseType == RopResponseType.RedirectResponse) { verifyMethodName = "Verify" + ropName + "RedirectResponse"; } Type reqType = ropRequest.GetType(); MethodInfo method = adapterType.GetMethod(verifyMethodName, BindingFlags.NonPublic | BindingFlags.Instance); if (method == null) { if (expectedRopResponseType == RopResponseType.SuccessResponse || expectedRopResponseType == RopResponseType.FailureResponse) { 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] = response; 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); paraObjects[i] = fieldInReq.GetValue(ropRequest); } 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); } return responseSOHs; }
/// <summary> /// Check whether the default invalid handle is needed. /// </summary> /// <param name="ropRequest">ROP request objects.</param> /// <param name="expectedRopResponseType">The expected ROP response type.</param> /// <returns>Return true if the default handle is needed in the request, otherwise return false.</returns> private bool IsInvalidInputHandleNeeded(ISerializable ropRequest, RopResponseType expectedRopResponseType) { if (!Common.IsOutputHandleInRopRequest(ropRequest) && expectedRopResponseType == RopResponseType.FailureResponse) { byte[] request = ropRequest.Serialize(); // The default handle is also needed by some cases to verify the failure response caused by an invalid input handle. // The input handle index is the third byte and its value is 1 in this test suite for this situation. byte inputHandleIndex = request[2]; if (inputHandleIndex == 1) { return true; } } return false; }
/// <summary> /// Verify adapter capture code using reflection mechanism. /// </summary> /// <param name="expectedRopResponseType">The Expected ROP response type.</param> /// <param name="response">ROP response object.</param> /// <param name="ropRequest">ROP request object.</param> private void VerifyAdapterCaptureCode(RopResponseType expectedRopResponseType, IDeserializable response, ISerializable ropRequest) { string resName = response.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. string verifyMethodName = string.Empty; if (expectedRopResponseType == RopResponseType.SuccessResponse) { verifyMethodName = "Verify" + ropName + "SuccessResponse"; } else if (expectedRopResponseType == RopResponseType.FailureResponse) { verifyMethodName = "Verify" + ropName + "FailureResponse"; } else if (expectedRopResponseType == RopResponseType.Response) { verifyMethodName = "Verify" + ropName + "Response"; } else if (expectedRopResponseType == RopResponseType.NullDestinationFailureResponse) { verifyMethodName = "Verify" + ropName + "NullDestinationFailureResponse"; } else if (expectedRopResponseType == RopResponseType.RedirectResponse) { verifyMethodName = "Verify" + ropName + "RedirectResponse"; } Type reqType = ropRequest.GetType(); MethodInfo method = adapterType.GetMethod(verifyMethodName, BindingFlags.NonPublic | BindingFlags.Instance); if (method == null) { if (expectedRopResponseType == RopResponseType.SuccessResponse || expectedRopResponseType == RopResponseType.FailureResponse) { 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] = response; 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); paraObjects[i] = fieldInReq.GetValue(ropRequest); } method.Invoke(this, paraObjects); } }
/// <summary> /// Method which executes single ROP with multiple server objects. /// </summary> /// <param name="ropRequest">ROP request object.</param> /// <param name="inputObjHandles">Server object handles in request.</param> /// <param name="response">ROP response object.</param> /// <param name="rawData">The ROP response payload.</param> /// <param name="expectedRopResponseType">ROP response type expected.</param> /// <returns>Server objects handles in response.</returns> public List<List<uint>> ProcessSingleRopWithMutipleServerObjects( ISerializable ropRequest, List<uint> inputObjHandles, ref IDeserializable response, ref byte[] rawData, RopResponseType expectedRopResponseType) { List<ISerializable> requestRops = new List<ISerializable> { ropRequest }; List<uint> requestSOH = new List<uint>(); for (int i = 0; i < inputObjHandles.Count; i++) { requestSOH.Add(inputObjHandles[i]); } if (Common.IsOutputHandleInRopRequest(ropRequest)) { // Add an element for server output object handle, set default value to 0xFFFFFFFF requestSOH.Add(DefaultOutputHandle); } List<IDeserializable> responseRops = new List<IDeserializable>(); 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; } if (responseRops != null) { if (responseRops.Count > 0) { response = responseRops[0]; } } else { response = null; } if (ropRequest.GetType() == typeof(RopReleaseRequest)) { return responseSOHs; } try { this.VerifyAdapterCaptureCode(expectedRopResponseType, response, ropRequest); } 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); } return responseSOHs; }
/// <summary> /// Method which executes multiple ROPs. /// </summary> /// <param name="requestRops">ROP request objects.</param> /// <param name="inputObjHandles">Server object handles in request.</param> /// <param name="responseRops">ROP response objects.</param> /// <param name="rawData">The ROP response payload.</param> /// <param name="expectedRopResponseType">The expected response type.</param> /// <returns>Server objects handles in response.</returns> 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; }
/// <summary> /// Method which executes single ROP. /// </summary> /// <param name="ropRequest">ROP request objects.</param> /// <param name="inputObjHandle">Server object handle in request.</param> /// <param name="response">ROP response objects.</param> /// <param name="rawData">The ROP response payload.</param> /// <param name="expectedRopResponseType">ROP response type expected.</param> /// <returns>Server objects handles in response.</returns> public List<List<uint>> ProcessSingleRop( ISerializable ropRequest, uint inputObjHandle, ref IDeserializable response, ref byte[] rawData, RopResponseType expectedRopResponseType) { uint returnValue; List<List<uint>> responseSOHs = this.ProcessSingleRopWithReturnValue(ropRequest, inputObjHandle, ref response, ref rawData, expectedRopResponseType, out returnValue); if (returnValue == 1726) { Site.Assert.AreEqual<RopResponseType>(RopResponseType.RPCError, expectedRopResponseType, "Unexpected RPC error {0} occurred.", returnValue); } return responseSOHs; }
/// <summary> /// Method which executes single ROP. /// </summary> /// <param name="ropRequest">ROP request objects.</param> /// <param name="inputObjHandle">Server object handle in request.</param> /// <param name="response">ROP response objects.</param> /// <param name="rawData">The ROP response payload.</param> /// <param name="expectedRopResponseType">ROP response type expected.</param> /// <param name="returnValue">The return value of the ROP method.</param> /// <returns>Server objects handles in response.</returns> public List<List<uint>> ProcessSingleRopWithReturnValue( ISerializable ropRequest, uint inputObjHandle, ref IDeserializable response, ref byte[] rawData, RopResponseType expectedRopResponseType, out uint returnValue) { List<ISerializable> requestRops = null; if (ropRequest != null) { requestRops = new List<ISerializable> { ropRequest }; } List<uint> requestSOH = new List<uint> { inputObjHandle }; if (Common.IsOutputHandleInRopRequest(ropRequest)) { // Add an element for server output object handle and set default value to 0xFFFFFFFF. requestSOH.Add(DefaultOutputHandle); } if (this.IsInvalidInputHandleNeeded(ropRequest, expectedRopResponseType)) { // Add an invalid input handle in request and set its value to 0xFFFFFFFF. requestSOH.Add(InvalidInputHandle); } List<IDeserializable> responseRops = new List<IDeserializable>(); List<List<uint>> responseSOHs = new List<List<uint>>(); uint ret = this.RopCall(requestRops, requestSOH, ref responseRops, ref responseSOHs, ref rawData, MaxRgbOut); returnValue = ret; if (ret != OxcRpcErrorCode.ECNone && ret != 1726) { Site.Assert.AreEqual<RopResponseType>(RopResponseType.RPCError, expectedRopResponseType, "Unexpected RPC error {0} occurred.", ret); return responseSOHs; } if (responseRops != null) { if (responseRops.Count > 0) { response = responseRops[0]; } } else { response = null; } if (ropRequest.GetType() == typeof(RopReleaseRequest)) { return responseSOHs; } if (response.GetType() == typeof(RopSaveChangesMessageResponse) && ((RopSaveChangesMessageResponse)response).ReturnValue == 0x80040401) { return responseSOHs; } if (response != null) { try { this.VerifyAdapterCaptureCode(expectedRopResponseType, response, ropRequest); } 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); } } return responseSOHs; }
/// <summary> /// Verify adapter capture code using reflection mechanism. /// </summary> /// <param name="expectedRopResponseType">The Expected ROP response type.</param> /// <param name="response">ROP response object.</param> /// <param name="ropRequest">ROP request object.</param> private void VerifyAdapterCaptureCode(RopResponseType expectedRopResponseType, IDeserializable response, ISerializable ropRequest) { string resName = response.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. string verifyMethodName = string.Empty; if (expectedRopResponseType == RopResponseType.SuccessResponse) { verifyMethodName = "Verify" + ropName + "SuccessResponse"; } else if (expectedRopResponseType == RopResponseType.FailureResponse) { verifyMethodName = "Verify" + ropName + "FailureResponse"; } else if (expectedRopResponseType == RopResponseType.Response) { verifyMethodName = "Verify" + ropName + "Response"; } else if (expectedRopResponseType == RopResponseType.NullDestinationFailureResponse) { verifyMethodName = "Verify" + ropName + "NullDestinationFailureResponse"; } else if (expectedRopResponseType == RopResponseType.RedirectResponse) { verifyMethodName = "Verify" + ropName + "RedirectResponse"; } Type reqType = ropRequest.GetType(); MethodInfo method = adapterType.GetMethod(verifyMethodName, BindingFlags.NonPublic | BindingFlags.Instance); if (method == null) { if (expectedRopResponseType == RopResponseType.SuccessResponse || expectedRopResponseType == RopResponseType.FailureResponse) { 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] = response; 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); paraObjects[i] = fieldInReq.GetValue(ropRequest); } method.Invoke(this, paraObjects); } }
/// <summary> /// Method which executes single ROP with multiple server objects. /// </summary> /// <param name="ropRequest">ROP request object.</param> /// <param name="inputObjHandles">Server object handles in request.</param> /// <param name="response">ROP response object.</param> /// <param name="rawData">The ROP response payload.</param> /// <param name="expectedRopResponseType">ROP response type expected.</param> /// <returns>Server objects handles in response.</returns> public List <List <uint> > ProcessSingleRopWithMutipleServerObjects( ISerializable ropRequest, List <uint> inputObjHandles, ref IDeserializable response, ref byte[] rawData, RopResponseType expectedRopResponseType) { List <ISerializable> requestRops = new List <ISerializable> { ropRequest }; List <uint> requestSOH = new List <uint>(); for (int i = 0; i < inputObjHandles.Count; i++) { requestSOH.Add(inputObjHandles[i]); } if (Common.IsOutputHandleInRopRequest(ropRequest)) { // Add an element for server output object handle, set default value to 0xFFFFFFFF requestSOH.Add(DefaultOutputHandle); } List <IDeserializable> responseRops = new List <IDeserializable>(); 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); } if (responseRops != null) { if (responseRops.Count > 0) { response = responseRops[0]; } } else { response = null; } if (ropRequest.GetType() == typeof(RopReleaseRequest)) { return(responseSOHs); } try { this.VerifyAdapterCaptureCode(expectedRopResponseType, response, ropRequest); } 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); } return(responseSOHs); }
/// <summary> /// Method which executes multiple ROPs. /// </summary> /// <param name="requestRops">ROP request objects.</param> /// <param name="inputObjHandles">Server object handles in request.</param> /// <param name="responseRops">ROP response objects.</param> /// <param name="rawData">The ROP response payload.</param> /// <param name="expectedRopResponseType">The expected response type.</param> /// <returns>Server objects handles in response.</returns> 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); }
/// <summary> /// Method which executes single ROP. /// </summary> /// <param name="ropRequest">ROP request objects.</param> /// <param name="inputObjHandle">Server object handle in request.</param> /// <param name="response">ROP response objects.</param> /// <param name="rawData">The ROP response payload.</param> /// <param name="expectedRopResponseType">ROP response type expected.</param> /// <param name="returnValue">The return value of the ROP method.</param> /// <returns>Server objects handles in response.</returns> public List <List <uint> > ProcessSingleRopWithReturnValue( ISerializable ropRequest, uint inputObjHandle, ref IDeserializable response, ref byte[] rawData, RopResponseType expectedRopResponseType, out uint returnValue) { List <ISerializable> requestRops = null; if (ropRequest != null) { requestRops = new List <ISerializable> { ropRequest }; } List <uint> requestSOH = new List <uint> { inputObjHandle }; if (Common.IsOutputHandleInRopRequest(ropRequest)) { // Add an element for server output object handle and set default value to 0xFFFFFFFF. requestSOH.Add(DefaultOutputHandle); } if (this.IsInvalidInputHandleNeeded(ropRequest, expectedRopResponseType)) { // Add an invalid input handle in request and set its value to 0xFFFFFFFF. requestSOH.Add(InvalidInputHandle); } List <IDeserializable> responseRops = new List <IDeserializable>(); List <List <uint> > responseSOHs = new List <List <uint> >(); uint ret = this.RopCall(requestRops, requestSOH, ref responseRops, ref responseSOHs, ref rawData, MaxRgbOut); returnValue = ret; if (ret != OxcRpcErrorCode.ECNone && ret != 1726) { Site.Assert.AreEqual <RopResponseType>(RopResponseType.RPCError, expectedRopResponseType, "Unexpected RPC error {0} occurred.", ret); return(responseSOHs); } if (responseRops != null) { if (responseRops.Count > 0) { response = responseRops[0]; } } else { response = null; } if (ropRequest.GetType() == typeof(RopReleaseRequest)) { return(responseSOHs); } if (response.GetType() == typeof(RopSaveChangesMessageResponse) && ((RopSaveChangesMessageResponse)response).ReturnValue == 0x80040401) { return(responseSOHs); } if (response != null) { try { this.VerifyAdapterCaptureCode(expectedRopResponseType, response, ropRequest); } 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); } } return(responseSOHs); }