Пример #1
0
        public void Insert(IEnumerable <Tuple <object, object> > kt)
        {
            //start node
            var startState =
                new BehaviorGraphNode(new OuterLoopBehaviorState());

            _nodes.Add(startState);

            Debug.Assert(kt != null);

            BehaviorGraphNode source = startState;

            foreach (var tuple in kt)
            {
                var strategy = tuple.Item1 as string;
                var tsExpr   = tuple.Item2 as List <TraceStepExpr>;
                Debug.Assert(strategy != null);
                Debug.Assert(tsExpr != null);

                var traceSteps    = tsExpr.Select(tse => tse.TraceStep).ToList();
                var outerEdgeProp = new OuterLoopEdgeProperty(strategy);
                var nodeState     = new OuterLoopBehaviorState(traceSteps);
                var target        = new BehaviorGraphNode(nodeState);
                _nodes.Add(target);

                var newEdge = new BehaviorGraphEdge(source, target, outerEdgeProp);
                source.OutEdges.Add(newEdge);
                target.InEdges.Add(newEdge);

                source = target;
            }
        }
Пример #2
0
        //multiple strategy
        public void Update(IEnumerable <Tuple <object, object> > traces)
        {
            Debug.Assert(Nodes[0] != null);
            BehaviorGraphNode source = Nodes[0];

            foreach (var tuple in traces)
            {
                var strategy = tuple.Item1 as string;
                var tsExpr   = tuple.Item2 as List <TraceStepExpr>;
                Debug.Assert(strategy != null);
                Debug.Assert(tsExpr != null);

                var traceSteps = tsExpr.Select(tse => tse.TraceStep).ToList();

                var outerNode = SearchOuterLoopNode(strategy);
                if (outerNode == null)
                {
                    var outerEdgeProp = new OuterLoopEdgeProperty(strategy);
                    var nodeState     = new OuterLoopBehaviorState(traceSteps);
                    outerNode = new BehaviorGraphNode(nodeState);
                    _nodes.Add(outerNode);
                    var newEdge = new BehaviorGraphEdge(source, outerNode, outerEdgeProp);
                    source.OutEdges.Add(newEdge);
                    outerNode.InEdges.Add(newEdge);
                    source = outerNode;
                }
                else
                {
                    Update(tsExpr, outerNode);
                }
            }
        }
Пример #3
0
        public void Insert(IEnumerable<Tuple<object, object>> kt)
        {
            //start node
            var startState =
                new BehaviorGraphNode(new OuterLoopBehaviorState());
            _nodes.Add(startState);

            Debug.Assert(kt != null);

            BehaviorGraphNode source = startState;
            foreach (var tuple in kt)
            {
                var strategy = tuple.Item1 as string;
                var tsExpr = tuple.Item2 as List<TraceStepExpr>;
                Debug.Assert(strategy != null);
                Debug.Assert(tsExpr != null);

                var traceSteps = tsExpr.Select(tse => tse.TraceStep).ToList();
                var outerEdgeProp = new OuterLoopEdgeProperty(strategy);
                var nodeState = new OuterLoopBehaviorState(traceSteps);
                var target = new BehaviorGraphNode(nodeState);
                _nodes.Add(target);

                var newEdge = new BehaviorGraphEdge(source, target, outerEdgeProp);
                source.OutEdges.Add(newEdge);
                target.InEdges.Add(newEdge);

                source = target;
            }
        }
Пример #4
0
        //multiple strategy
        public void Update(IEnumerable<Tuple<object, object>> traces)
        {
            Debug.Assert(Nodes[0] != null);
            BehaviorGraphNode source = Nodes[0];
            foreach (var tuple in traces)
            {
                var strategy = tuple.Item1 as string;
                var tsExpr = tuple.Item2 as List<TraceStepExpr>;
                Debug.Assert(strategy != null);
                Debug.Assert(tsExpr != null);

                var traceSteps = tsExpr.Select(tse => tse.TraceStep).ToList();

                var outerNode = SearchOuterLoopNode(strategy);
                if (outerNode == null)
                {
                    var outerEdgeProp = new OuterLoopEdgeProperty(strategy);
                    var nodeState = new OuterLoopBehaviorState(traceSteps);
                    outerNode = new BehaviorGraphNode(nodeState);
                    _nodes.Add(outerNode);
                    var newEdge = new BehaviorGraphEdge(source, outerNode, outerEdgeProp);
                    source.OutEdges.Add(newEdge);
                    outerNode.InEdges.Add(newEdge);
                    source = outerNode;
                }
                else
                {
                    Update(tsExpr, outerNode);
                }               
            }
        }