Exemple #1
0
        public IExpressionExecutor Create(IDictionary <Type, Type> functionTypeToHandlerTypeMap)
        {
            IExpressionExecutor expressionExecutor = null;

            expressionExecutor = new ExpressionExecutor(new ConstantExpressionExecutor(),
                                                        new FunctionExpressionExecutor(new FunctionParametersFiller(new Lazy <IExpressionExecutor>(() => expressionExecutor)),
                                                                                       new DictionarySourcedActivatorUsingFunctionHandlerResolver(functionTypeToHandlerTypeMap)),
                                                        new BatchExpressionExecutor(new Lazy <IExpressionExecutor>(() => expressionExecutor)));

            return(expressionExecutor);
        }
Exemple #2
0
 public IEnumerable <UiNode> Search(UiNode root, IExpressionExecutor filter, int max = int.MaxValue)
 {
     try
     {
         //添加任务
         return(SearchChild(root, filter, max));
     }
     catch (Exception)
     {
         return(new List <UiNode>());
     }
 }
Exemple #3
0
        private static IEnumerable <UiNode> SearchChild(UiNode root, IExpressionExecutor filter, int max)
        {
            var result = new List <UiNode>();
            var stack  = new Queue <UiNode>();

            stack.Enqueue(root);
            while (stack.Count > 0)
            {
                var parent = stack.Dequeue();

                for (var i = 0; i < parent.ChildCount; i++)
                {
                    var child = parent.Child(i);
                    if (child == null)
                    {
                        continue;
                    }

                    stack.Enqueue(child);
                }

                if (filter.Execute(parent))
                {
                    result.Add(parent);

                    if (result.Count >= max)
                    {
                        break;
                    }
                }
                else
                {
                    if (parent != root)
                    {
                        parent.Recycle();
                    }
                }
            }

            return(result);
        }
Exemple #4
0
        private object Act(IBatchExpression expression, IExpressionExecutor expressionExecutor)
        {
            var executor = new BatchExpressionExecutor(new Lazy <IExpressionExecutor>(() => expressionExecutor));

            return(executor.Execute(expression));
        }
Exemple #5
0
        private void Act <TFunction>(TFunction function, IDictionary <string, IExpression> argumentExpressions, IExpressionExecutor expressionExecutor = null)
        {
            var filler = new FunctionParametersFiller(new Lazy <IExpressionExecutor>(() => expressionExecutor));

            filler.Fill(function, argumentExpressions);
        }