Ejemplo n.º 1
0
        private bool CollectExecutors(HandlerInvokeGraph invokeGraph, EntityNode entityNode, int argumentIndex)
        {
            HandlerArgument argument = this.HandlerArguments[argumentIndex];

            if (argumentIndex == (this.HandlerArguments.Count - 1))
            {
                HandlerExecutor item = this.CreateExecutor();
                item.ArgumentForMethod[argumentIndex + 1] = entityNode.invokeArgument;
                this.handlerExecutors.Add(item);
                return(true);
            }
            ArgumentNode      argumentNode = invokeGraph.ArgumentNodes[argumentIndex + 1];
            List <EntityNode> source       = (argument.Collection || argumentNode.linkBreak) ? argumentNode.entityNodes : entityNode.nextArgumentEntityNodes;
            int  count = this.handlerExecutors.Count;
            bool flag  = false;

            for (int i = 0; i < source.Count <EntityNode>(); i++)
            {
                if (this.CollectExecutors(invokeGraph, source[i], argumentIndex + 1))
                {
                    if (flag && !argumentNode.argument.Combine)
                    {
                        throw new IllegalCombineException(this.Handler, argumentNode);
                    }
                    flag = true;
                }
            }
            for (int j = count; j < this.handlerExecutors.Count; j++)
            {
                this.handlerExecutors[j].ArgumentForMethod[argumentIndex + 1] = entityNode.invokeArgument;
            }
            return(flag);
        }
Ejemplo n.º 2
0
        public virtual void Update(Event eventInstance, HandlerInvokeGraph invokeGraph)
        {
            this.handlerVersion = this.Handler.Version;
            this.handlerExecutors.Clear();
            ArgumentNode      argumentNode = invokeGraph.ArgumentNodes[0];
            List <EntityNode> entityNodes  = argumentNode.entityNodes;
            HandlerArgument   argument     = argumentNode.argument;
            bool flag = false;

            for (int i = 0; i < entityNodes.Count; i++)
            {
                if (this.CollectExecutors(invokeGraph, entityNodes[i], 0))
                {
                    if (!argument.Combine && flag)
                    {
                        throw new IllegalCombineException(this.Handler, argumentNode);
                    }
                    flag = true;
                }
            }
            if (!flag)
            {
                throw new InvalidInvokeGraphException(this.Handler);
            }
            for (int j = 0; j < this.handlerExecutors.Count; j++)
            {
                this.handlerExecutors[j].SetEvent(eventInstance);
            }
        }
Ejemplo n.º 3
0
        protected bool UpdateInvokeData(HandlerInvokeData invokeData, Handler handler, Event eventInstance, Entity entity, ICollection <NodeDescription> changedNodes)
        {
            HandlerInvokeGraph handlerInvokeGraph = handler.HandlerInvokeGraph.Init();
            bool flag = reverseCombinator.Combine(handlerInvokeGraph, entity, changedNodes) && combinator.Combine(handlerInvokeGraph, null);

            if (flag)
            {
                invokeData.Update(eventInstance, handlerInvokeGraph);
            }
            handlerInvokeGraph.Clear();
            return(flag);
        }
Ejemplo n.º 4
0
 private void Finalize(HandlerInvokeGraph handlerInvokeGraph)
 {
     foreach (ArgumentNode node in handlerInvokeGraph.ArgumentNodes)
     {
         node.PrepareInvokeArguments();
         if (node.argument.Collection)
         {
             node.ConvertToCollection();
         }
         else if (node.argument.Optional)
         {
             node.ConvertToOptional();
         }
     }
 }
Ejemplo n.º 5
0
        public bool Combine(HandlerInvokeGraph handlerInvokeGraph, Entity contextEntity, ICollection <NodeDescription> changedNodes)
        {
            ArgumentNode[] argumentNodes    = handlerInvokeGraph.ArgumentNodes;
            ArgumentNode   fromArgumentNode = null;

            for (int i = argumentNodes.Length - 1; i >= 0; i--)
            {
                ArgumentNode toArgumentNode = argumentNodes[i];
                if (!this.FillEntityNodes(fromArgumentNode, toArgumentNode, contextEntity, changedNodes))
                {
                    Handler handler = handlerInvokeGraph.Handler;
                    return(false);
                }
                fromArgumentNode = toArgumentNode;
            }
            return(true);
        }
Ejemplo n.º 6
0
        protected virtual bool UpdateInvokeData(HandlerInvokeData invokeData, Handler handler, Event eventInstance, ICollection <Entity> contextEntities)
        {
            if (handler.IsEventOnlyArguments)
            {
                invokeData.UpdateForEventOnlyArguments(eventInstance);
                return(true);
            }
            HandlerInvokeGraph handlerInvokeGraph = handler.HandlerInvokeGraph.Init();
            bool flag = combinator.Combine(handlerInvokeGraph, contextEntities);

            if (flag)
            {
                invokeData.Update(eventInstance, handlerInvokeGraph);
            }
            else
            {
                invokeData.UpdateForEmptyCall();
            }
            handlerInvokeGraph.Clear();
            return(flag);
        }
Ejemplo n.º 7
0
        public virtual bool Combine(HandlerInvokeGraph handlerInvokeGraph, ICollection <Entity> contextEntities)
        {
            ArgumentNode[] argumentNodes    = handlerInvokeGraph.ArgumentNodes;
            ArgumentNode   fromArgumentNode = null;
            Handler        handler          = handlerInvokeGraph.Handler;

            for (int i = 0; i < argumentNodes.Length; i++)
            {
                ArgumentNode toArgumentNode = argumentNodes[i];
                if (!this.FillEntityNodes(contextEntities, fromArgumentNode, toArgumentNode))
                {
                    if (handler.Mandatory || toArgumentNode.argument.Mandatory)
                    {
                        throw new MandatoryException(SkipInfoBuilder.GetSkipReasonDetails(handler, fromArgumentNode, toArgumentNode, toArgumentNode.argument.JoinType));
                    }
                    return(false);
                }
                fromArgumentNode = toArgumentNode;
            }
            this.Finalize(handlerInvokeGraph);
            return(true);
        }