internal static void PropagateOutParameters(IMessage msg, object[] outArgs, object returnValue) { Message message = msg as Message; if (message == null) { ConstructorCallMessage message2 = msg as ConstructorCallMessage; if (message2 != null) { message = message2.GetMessage(); } } if (message == null) { throw new ArgumentException(Environment.GetResourceString("Remoting_Proxy_ExpectedOriginalMessage")); } RemotingMethodCachedData reflectionCachedData = InternalRemotingServices.GetReflectionCachedData(message.GetMethodBase()); if ((outArgs != null) && (outArgs.Length > 0)) { object[] args = message.Args; ParameterInfo[] parameters = reflectionCachedData.Parameters; foreach (int num in reflectionCachedData.MarshalRequestArgMap) { ParameterInfo info = parameters[num]; if ((info.IsIn && info.ParameterType.IsByRef) && !info.IsOut) { outArgs[num] = args[num]; } } if (reflectionCachedData.NonRefOutArgMap.Length > 0) { foreach (int num2 in reflectionCachedData.NonRefOutArgMap) { Array destinationArray = args[num2] as Array; if (destinationArray != null) { Array.Copy((Array)outArgs[num2], destinationArray, destinationArray.Length); } } } int[] outRefArgMap = reflectionCachedData.OutRefArgMap; if (outRefArgMap.Length > 0) { foreach (int num3 in outRefArgMap) { ValidateReturnArg(outArgs[num3], parameters[num3].ParameterType); } } } if ((message.GetCallType() & 15) != 1) { Type returnType = reflectionCachedData.ReturnType; if (returnType != null) { ValidateReturnArg(returnValue, returnType); } } message.PropagateOutParameters(outArgs, returnValue); }
internal static void PropagateOutParameters(IMessage msg, object[] outArgs, object returnValue) { Message message = msg as Message; if (message == null) { ConstructorCallMessage constructorCallMessage = msg as ConstructorCallMessage; if (constructorCallMessage != null) { message = constructorCallMessage.GetMessage(); } } if (message == null) { throw new ArgumentException(Environment.GetResourceString("Remoting_Proxy_ExpectedOriginalMessage")); } RemotingMethodCachedData reflectionCachedData = InternalRemotingServices.GetReflectionCachedData(message.GetMethodBase()); if (outArgs != null && outArgs.Length != 0) { object[] args = message.Args; ParameterInfo[] parameters = reflectionCachedData.Parameters; foreach (int marshalRequestArg in reflectionCachedData.MarshalRequestArgMap) { ParameterInfo parameterInfo = parameters[marshalRequestArg]; if (parameterInfo.IsIn && parameterInfo.ParameterType.IsByRef && !parameterInfo.IsOut) { outArgs[marshalRequestArg] = args[marshalRequestArg]; } } if (reflectionCachedData.NonRefOutArgMap.Length != 0) { foreach (int nonRefOutArg in reflectionCachedData.NonRefOutArgMap) { Array array = args[nonRefOutArg] as Array; if (array != null) { Array sourceArray = (Array)outArgs[nonRefOutArg]; Array destinationArray = array; int length = destinationArray.Length; Array.Copy(sourceArray, destinationArray, length); } } } int[] outRefArgMap = reflectionCachedData.OutRefArgMap; if (outRefArgMap.Length != 0) { foreach (int index in outRefArgMap) { RealProxy.ValidateReturnArg(outArgs[index], parameters[index].ParameterType); } } } if ((message.GetCallType() & 15) != 1) { Type returnType = reflectionCachedData.ReturnType; if (returnType != (Type)null) { RealProxy.ValidateReturnArg(returnValue, returnType); } } message.PropagateOutParameters(outArgs, returnValue); }
[System.Security.SecurityCritical] // auto-generated internal static void PropagateOutParameters(IMessage msg, Object[] outArgs, Object returnValue) { // Check for method call Message m = msg as Message; // Check for constructor call if (null == m) { ConstructorCallMessage ccm = msg as ConstructorCallMessage; if (null != ccm) { m = ccm.GetMessage(); } } if (null == m) { throw new ArgumentException( Environment.GetResourceString("Remoting_Proxy_ExpectedOriginalMessage")); } MethodBase mb = m.GetMethodBase(); RemotingMethodCachedData cache = InternalRemotingServices.GetReflectionCachedData(mb); if (outArgs != null && outArgs.Length > 0) { Object[] args = m.Args; // original arguments // If a byref parameter is marked only with [In], we need to copy the // original value from the request message into outargs, so that the // value won't be bashed by CMessage::PropagateOutParameters below. ParameterInfo[] parameters = cache.Parameters; foreach (int index in cache.MarshalRequestArgMap) { ParameterInfo param = parameters[index]; if (param.IsIn && param.ParameterType.IsByRef) { if (!param.IsOut) { outArgs[index] = args[index]; } } } // copy non-byref arrays back into the same instance if (cache.NonRefOutArgMap.Length > 0) { foreach (int index in cache.NonRefOutArgMap) { Array arg = args[index] as Array; if (arg != null) { Array.Copy((Array)outArgs[index], arg, arg.Length); } } } // validate by-ref args (This must be done last) int[] outRefArgMap = cache.OutRefArgMap; if (outRefArgMap.Length > 0) { foreach (int index in outRefArgMap) { ValidateReturnArg(outArgs[index], parameters[index].ParameterType); } } } // validate return value // (We don't validate Message.BeginAsync because the return value // is always an IAsyncResult and the method base is the one that // represents the underlying synchronous method). int callType = m.GetCallType(); if ((callType & Message.CallMask) != Message.BeginAsync) { Type returnType = cache.ReturnType; if (returnType != null) { ValidateReturnArg(returnValue, returnType); } } m.PropagateOutParameters(outArgs, returnValue); } // PropagateOutParameters