コード例 #1
0
        /// <summary>
        /// Compiles the input linqExpression into a Linq expression tree
        /// </summary>
        /// <param name="linqExpression">The linqExpression.</param>
        /// <returns></returns>
        public Action <object, object> CompileAction(LinqExpressionToRun linqExpression)
        {
            if (linqExpression.Unique) //don't bother caching
            {
                _counterActionCacheUnique.Increment();
                return(_handler.CompileAction(linqExpression));
            }

            var key    = GenerateKey(linqExpression);
            var result = (Action <object, object>)_cache[key];

            if (result != null)
            {
                _counterActionCacheHit.Increment(key);
                return(result);
            }

            result = _handler.CompileAction(linqExpression);
            if (!_cache.Exists(key))
            {
                _counterActionCacheMiss.Increment(key);
                _cache.Add(key, result);
                _cache.Expire(key, ExpirationMode.Sliding, _itemPolicy.SlidingExpiration);
            }

            return(result);
        }
コード例 #2
0
        /// <summary>
        /// Compiles the input linqExpression into a Linq expression tree
        /// </summary>
        /// <param name="linqExpression">The linqExpression.</param>
        /// <returns></returns>
        public Action <object, object> CompileAction(LinqExpressionToRun linqExpression)
        {
            if (linqExpression.Unique) //don't bother caching
            {
                _counterActionCacheUnique.Increment();
                return(_handler.CompileAction(linqExpression));
            }

            var key = GenerateKey(linqExpression);

            return(_cacheActions.Execute(context => _handler.CompileAction(linqExpression), new Context(key)));
        }
コード例 #3
0
 /// <summary>
 /// Compiles the input linqExpression into a Linq expression tree
 /// </summary>
 /// <param name="linqExpression">The linqExpression.</param>
 /// <returns></returns>
 public Action <object, object> CompileAction(LinqExpressionToRun linqExpression)
 {
     using (_compileActionTimer.NewContext())
     {
         return(_handler.CompileAction(linqExpression));
     }
 }
コード例 #4
0
        /// <inheritdoc />
        public void HandleExecution(IReceivedMessage <MessageExpression> receivedMessage, IWorkerNotification workerNotification)
        {
            ThrowIfDisposed();
            Guard.NotNull(() => receivedMessage, receivedMessage);
            Guard.NotNull(() => workerNotification, workerNotification);

            switch (receivedMessage.Body.PayLoad)
            {
            case MessageExpressionPayloads.Action:
                HandleAction(receivedMessage, workerNotification);
                break;

            case MessageExpressionPayloads.ActionRaw:
                HandleRawAction(receivedMessage, workerNotification);
                break;

            case MessageExpressionPayloads.ActionText:
                var targetMethod =
                    _linqCompiler.CompileAction(
                        _compositeSerialization.InternalSerializer.ConvertBytesTo <LinqExpressionToRun>(
                            receivedMessage.Body.SerializedExpression));

                try
                {
                    HandleAction(targetMethod, 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;
                }

                break;

            default:
                throw new DotNetWorkQueueException($"The method type of {receivedMessage.Body.PayLoad} is not implemented");
            }
        }