Invoke() public abstract méthode

public abstract Invoke ( IMessage msg ) : IMessage
msg IMessage
Résultat IMessage
		private static void InvokeRealProxy(RealProxy realProxy, WcfInvocation wcfInvocation)
		{
			var message = new MethodCallMessage(wcfInvocation.Method, wcfInvocation.Arguments);
			var returnMessage = (IMethodReturnMessage)realProxy.Invoke(message);
			if (returnMessage.Exception != null)
			{
				throw returnMessage.Exception;
			}
			wcfInvocation.ReturnValue = returnMessage.ReturnValue;
		}
		private static void InvokeRealProxy(RealProxy realProxy, WcfInvocation wcfInvocation)
		{
			var message = new MethodCallMessage(wcfInvocation.Method, wcfInvocation.Arguments);
			var returnMessage = (IMethodReturnMessage)realProxy.Invoke(message);
			if (returnMessage.Exception != null)
			{
				var exception = ExceptionHelper.PreserveStackTrace(returnMessage.Exception);
				throw exception;
			}
			wcfInvocation.ReturnValue = returnMessage.ReturnValue;
		}
Exemple #3
0
		/* this is called from unmanaged code */
		internal static object PrivateInvoke (RealProxy rp, IMessage msg, out Exception exc,
						      out object [] out_args)
		{
			MonoMethodMessage mMsg = (MonoMethodMessage) msg;
			mMsg.LogicalCallContext = CallContext.CreateLogicalCallContext (true);
			CallType call_type = mMsg.CallType;
#if MOONLIGHT
			bool is_remproxy = false;
#else
			bool is_remproxy = (rp is RemotingProxy);
#endif

			out_args = null;
			IMethodReturnMessage res_msg = null;
			
			if (call_type == CallType.BeginInvoke) 
				// todo: set CallMessage in runtime instead
				mMsg.AsyncResult.CallMessage = mMsg;

			if (call_type == CallType.EndInvoke)
				res_msg = (IMethodReturnMessage)mMsg.AsyncResult.EndInvoke ();

			// Check for constructor msg
			if (mMsg.MethodBase.IsConstructor) 
			{
#if !MOONLIGHT
				if (is_remproxy) 
					res_msg = (IMethodReturnMessage) (rp as RemotingProxy).ActivateRemoteObject ((IMethodMessage) msg);
				else 
#endif
					msg = new ConstructionCall (rp.GetProxiedType ());
			}
				
			if (null == res_msg) 
			{
				bool failed = false;
				
				try {
					res_msg = (IMethodReturnMessage)rp.Invoke (msg);
				} catch (Exception ex) {
					failed = true;
					if (call_type == CallType.BeginInvoke) {
						// If async dispatch crashes, don't propagate the exception.
						// The exception will be raised when calling EndInvoke.
						mMsg.AsyncResult.SyncProcessMessage (new ReturnMessage (ex, msg as IMethodCallMessage));
						res_msg = new ReturnMessage (null, null, 0, null, msg as IMethodCallMessage);
					} else
						throw;
				}
				
				// Note, from begining this code used AsyncResult.IsCompleted for
				// checking if it was a remoting or custom proxy, but in some
				// cases the remoting proxy finish before the call returns
				// causing this method to be called, therefore causing all kind of bugs.
				if ((!is_remproxy) && call_type == CallType.BeginInvoke && !failed)
				{
					IMessage asyncMsg = null;

					// allow calltype EndInvoke to finish
					asyncMsg = mMsg.AsyncResult.SyncProcessMessage (res_msg as IMessage);
					out_args = res_msg.OutArgs;
					res_msg = new ReturnMessage (asyncMsg, null, 0, null, res_msg as IMethodCallMessage);
				}
			}
			
			if (res_msg.LogicalCallContext != null && res_msg.LogicalCallContext.HasInfo)
				CallContext.UpdateCurrentCallContext (res_msg.LogicalCallContext);

			exc = res_msg.Exception;

			// todo: remove throw exception from the runtime invoke
			if (null != exc) {
				out_args = null;
				throw exc.FixRemotingException();
			}
			else if (res_msg is IConstructionReturnMessage) {
				if (out_args == null)
					out_args = res_msg.OutArgs;
			}
			else if (mMsg.CallType == CallType.BeginInvoke) {
				// We don't have OutArgs in this case.
			}
			else if (mMsg.CallType == CallType.Sync) {
				out_args = ProcessResponse (res_msg, mMsg);
			}
			else if (mMsg.CallType == CallType.EndInvoke) {
				out_args = ProcessResponse (res_msg, mMsg.AsyncResult.CallMessage);
			}
			else {
				if (out_args == null)
					out_args = res_msg.OutArgs;
			}

			return res_msg.ReturnValue;
		}
Exemple #4
0
        /* this is called from unmanaged code */
        internal static object PrivateInvoke(RealProxy rp, IMessage msg, out Exception exc,
                                             out object [] out_args)
        {
            MonoMethodMessage mMsg = (MonoMethodMessage)msg;

            mMsg.LogicalCallContext = CallContext.CreateLogicalCallContext(true);
            CallType call_type   = mMsg.CallType;
            bool     is_remproxy = (rp is RemotingProxy);

            out_args = null;
            IMethodReturnMessage res_msg = null;

            if (call_type == CallType.BeginInvoke)
            {
                // todo: set CallMessage in runtime instead
                mMsg.AsyncResult.CallMessage = mMsg;
            }

            if (call_type == CallType.EndInvoke)
            {
                res_msg = (IMethodReturnMessage)mMsg.AsyncResult.EndInvoke();
            }

            // Check for constructor msg
            if (mMsg.MethodBase.IsConstructor)
            {
                if (is_remproxy)
                {
                    res_msg = (IMethodReturnMessage)(rp as RemotingProxy).ActivateRemoteObject((IMethodMessage)msg);
                }
                else
                {
                    msg = new ConstructionCall(rp.GetProxiedType());
                }
            }

            if (null == res_msg)
            {
                bool failed = false;

                try {
                    res_msg = (IMethodReturnMessage)rp.Invoke(msg);
                } catch (Exception ex) {
                    failed = true;
                    if (call_type == CallType.BeginInvoke)
                    {
                        // If async dispatch crashes, don't propagate the exception.
                        // The exception will be raised when calling EndInvoke.
                        mMsg.AsyncResult.SyncProcessMessage(new ReturnMessage(ex, msg as IMethodCallMessage));
                        res_msg = new ReturnMessage(null, null, 0, null, msg as IMethodCallMessage);
                    }
                    else
                    {
                        throw;
                    }
                }

                // Note, from begining this code used AsyncResult.IsCompleted for
                // checking if it was a remoting or custom proxy, but in some
                // cases the remoting proxy finish before the call returns
                // causing this method to be called, therefore causing all kind of bugs.
                if ((!is_remproxy) && call_type == CallType.BeginInvoke && !failed)
                {
                    IMessage asyncMsg = null;

                    // allow calltype EndInvoke to finish
                    asyncMsg = mMsg.AsyncResult.SyncProcessMessage(res_msg as IMessage);
                    out_args = res_msg.OutArgs;
                    res_msg  = new ReturnMessage(asyncMsg, null, 0, null, res_msg as IMethodCallMessage);
                }
            }

            if (res_msg.LogicalCallContext != null && res_msg.LogicalCallContext.HasInfo)
            {
                CallContext.UpdateCurrentCallContext(res_msg.LogicalCallContext);
            }

            exc = res_msg.Exception;

            // todo: remove throw exception from the runtime invoke
            if (null != exc)
            {
                out_args = null;
                throw exc.FixRemotingException();
            }
            else if (res_msg is IConstructionReturnMessage)
            {
                if (out_args == null)
                {
                    out_args = res_msg.OutArgs;
                }
            }
            else if (mMsg.CallType == CallType.BeginInvoke)
            {
                // We don't have OutArgs in this case.
            }
            else if (mMsg.CallType == CallType.Sync)
            {
                out_args = ProcessResponse(res_msg, mMsg);
            }
            else if (mMsg.CallType == CallType.EndInvoke)
            {
                out_args = ProcessResponse(res_msg, mMsg.AsyncResult.CallMessage);
            }
            else
            {
                if (out_args == null)
                {
                    out_args = res_msg.OutArgs;
                }
            }

            return(res_msg.ReturnValue);
        }
Exemple #5
0
        internal static object PrivateInvoke(RealProxy rp, IMessage msg, out Exception exc, out object[] out_args)
        {
            MonoMethodMessage monoMethodMessage = (MonoMethodMessage)msg;

            monoMethodMessage.LogicalCallContext = CallContext.CreateLogicalCallContext(true);
            CallType callType = monoMethodMessage.CallType;
            bool     flag     = rp is RemotingProxy;

            out_args = null;
            IMethodReturnMessage methodReturnMessage = null;

            if (callType == CallType.BeginInvoke)
            {
                monoMethodMessage.AsyncResult.CallMessage = monoMethodMessage;
            }
            if (callType == CallType.EndInvoke)
            {
                methodReturnMessage = (IMethodReturnMessage)monoMethodMessage.AsyncResult.EndInvoke();
            }
            if (monoMethodMessage.MethodBase.IsConstructor)
            {
                if (flag)
                {
                    methodReturnMessage = (IMethodReturnMessage)(rp as RemotingProxy).ActivateRemoteObject((IMethodMessage)msg);
                }
                else
                {
                    msg = new ConstructionCall(rp.GetProxiedType());
                }
            }
            if (methodReturnMessage == null)
            {
                bool flag2 = false;
                try
                {
                    methodReturnMessage = (IMethodReturnMessage)rp.Invoke(msg);
                }
                catch (Exception e)
                {
                    flag2 = true;
                    if (callType != CallType.BeginInvoke)
                    {
                        throw;
                    }
                    monoMethodMessage.AsyncResult.SyncProcessMessage(new ReturnMessage(e, msg as IMethodCallMessage));
                    methodReturnMessage = new ReturnMessage(null, null, 0, null, msg as IMethodCallMessage);
                }
                if (!flag && callType == CallType.BeginInvoke && !flag2)
                {
                    IMessage ret = monoMethodMessage.AsyncResult.SyncProcessMessage(methodReturnMessage);
                    out_args            = methodReturnMessage.OutArgs;
                    methodReturnMessage = new ReturnMessage(ret, null, 0, null, methodReturnMessage as IMethodCallMessage);
                }
            }
            if (methodReturnMessage.LogicalCallContext != null && methodReturnMessage.LogicalCallContext.HasInfo)
            {
                CallContext.UpdateCurrentCallContext(methodReturnMessage.LogicalCallContext);
            }
            exc = methodReturnMessage.Exception;
            if (exc != null)
            {
                out_args = null;
                throw exc.FixRemotingException();
            }
            if (methodReturnMessage is IConstructionReturnMessage)
            {
                if (out_args == null)
                {
                    out_args = methodReturnMessage.OutArgs;
                }
            }
            else if (monoMethodMessage.CallType != CallType.BeginInvoke)
            {
                if (monoMethodMessage.CallType == CallType.Sync)
                {
                    out_args = RealProxy.ProcessResponse(methodReturnMessage, monoMethodMessage);
                }
                else if (monoMethodMessage.CallType == CallType.EndInvoke)
                {
                    out_args = RealProxy.ProcessResponse(methodReturnMessage, monoMethodMessage.AsyncResult.CallMessage);
                }
                else if (out_args == null)
                {
                    out_args = methodReturnMessage.OutArgs;
                }
            }
            return(methodReturnMessage.ReturnValue);
        }