示例#1
0
 /// <summary>
 /// Converts the bytes back to the function.
 /// </summary>
 /// <param name="bytes">The bytes.</param>
 /// <returns></returns>
 public Expression <Func <IReceivedMessage <MessageExpression>, IWorkerNotification, object> > ConvertBytesToFunction(byte[] bytes)
 {
     using (_bytesToFunctionTimer.NewContext())
     {
         return(_handler.ConvertBytesToFunction(bytes));
     }
 }
        /// <summary>
        /// De-serializes and runs a compiled linq func expression.
        /// </summary>
        /// <param name="receivedMessage">The received message.</param>
        /// <param name="workerNotification">The worker notification.</param>
        private void HandleFunction(IReceivedMessage <MessageExpression> receivedMessage,
                                    IWorkerNotification workerNotification)
        {
            var target = _serializer.ConvertBytesToFunction(receivedMessage.Body.SerializedExpression);

            try
            {
                HandleFunction(target.Compile(), receivedMessage, workerNotification);
            }
            catch (Exception error) //throw the real exception if needed
            {
                if (error.Message == "Exception has been thrown by the target of an invocation." &&
                    error.InnerException != null)
                {
                    throw error.InnerException;
                }
                throw;
            }
        }