예제 #1
0
        private static void runActions(ContextPool pool, ActionBlock actionBlock, NodesSubstitution substitutions = null, bool useFiltering = true)
        {
            if (substitutions != null)
            {
                pool.SetSubstitutions(substitutions);
            }

            var sortedActions = actionBlock.Actions.OrderByDescending((a) => a.Priority).ToArray();
            var hasPushAction = sortedActions.Any(action => action is PushAction);

            if (hasPushAction)
            {
                //start new topic - but only once! (multiple pushes can appear)
                pool.ClearAccumulator();
            }

            foreach (var action in sortedActions)
            {
                action.Run(pool);
            }

            if (useFiltering && pool.ActiveCount > 1)
            {
                pool.Filter(actionBlock.OutputFilter);
            }
        }
예제 #2
0
        internal void SetSubstitutions(NodesSubstitution substitutions)
        {
            _substitutions = new Dictionary <NodeReference, NodeReference>();

            if (substitutions == null)
            {
                //nothing more to substitute
                return;
            }

            for (var nodeIndex = 0; nodeIndex < substitutions.NodeCount; ++nodeIndex)
            {
                var key          = substitutions.GetOriginalNode(nodeIndex);
                var substitution = substitutions.GetSubstitution(nodeIndex);
                _substitutions[key] = substitution;
            }
        }
예제 #3
0
 public PoolHypothesis(NodesSubstitution substitutions, MappingControl <ActionBlock> control)
 {
     Substitutions = substitutions;
     ActionBlock   = control.Value;
     Control       = control;
 }