//------------------------------------------------------------------------------
        //
        // Method: ReceiveMethodInvocation
        //
        //------------------------------------------------------------------------------
        /// <summary>
        /// Method called when a remote method invocation is received.
        /// </summary>
        /// <param name="sender">The object which received the method invocation.</param>
        /// <param name="e">The event arguments of the receive operation, include the method invocation.</param>
        private void ReceiveMethodInvocation(object sender, MethodInvocationReceivedEventArgs e)
        {
            // Call the relevant methods on the presenter
            if (e.MethodInvocation.Name == "AddUpdateContact")
            {
                object[] parameters = e.MethodInvocation.Parameters;

                presenter.AddUpdateContact((string)parameters[0], (string)parameters[1], (string)parameters[2], (string)parameters[3]);
                ((IMethodInvocationRemoteReceiver)sender).SendVoidReturn();
            }
            else if (e.MethodInvocation.Name == "DeleteContact")
            {
                presenter.DeleteContact((string)e.MethodInvocation.Parameters[0]);
                ((IMethodInvocationRemoteReceiver)sender).SendVoidReturn();
            }
            else if (e.MethodInvocation.Name == "Exit")
            {
                presenter.Exit();
                ((IMethodInvocationRemoteReceiver)sender).SendVoidReturn();
            }
            else
            {
                throw new NotImplementedException("Received unhandled method invocation '" + e.MethodInvocation.Name + "'.");
            }
        }
Example #2
0
        /// <summary>
        /// The event that is raised when a remote method invocation is received.
        /// </summary>
        /// <param name="sender">The object which raised the event.</param>
        /// <param name="e">The method invocation which was received.</param>
        private static void ReceiveMethodInvocation(object sender, MethodInvocationReceivedEventArgs e)
        {
            if (e.MethodInvocation.Name == "ApproximatePi")
            {
                object[] parameters = e.MethodInvocation.Parameters;

                Console.WriteLine("Received invocation of method 'ApproximatePi(" + (int)parameters[0] + ")'");
                // Call the ApproximatePi method
                decimal result = ApproximatePi((int)parameters[0]);
                Console.WriteLine("Sending return value " + result.ToString());
                // Send the result
                ((IMethodInvocationRemoteReceiver)sender).SendReturnValue(result);
            }
            else
            {
                throw new NotImplementedException("Received unhandled method invocation '" + e.MethodInvocation.Name + "'.");
            }
        }
 private void SimulateMethodInvocationReceive(object sender, MethodInvocationReceivedEventArgs e)
 {
 }