コード例 #1
0
        /// <summary>
        /// Applies this step activation be registering it in the activation cache
        /// </summary>
        public override void Apply()
        {
            base.Apply();

            TimeLine.SubStepActivationCache[SubStep] = this;
            foreach (VariableUpdate update in Updates)
            {
                TimeLine.AddModelEvent(update);
            }

            // Store the step corresponding expectations
            foreach (Expectation expectation in subStep.Expectations)
            {
                TimeLine.AddModelEvent(new Events.Expect(expectation));
            }
        }
コード例 #2
0
        /// <summary>
        ///     Applies this step activation be registering it in the activation cache
        /// </summary>
        /// <param name="runner"></param>
        public override void Apply(Runner runner)
        {
            base.Apply(runner);

            TimeLine.SubStepActivationCache[SubStep] = this;
            foreach (VariableUpdate update in Updates)
            {
                TimeLine.AddModelEvent(update, true);
            }

            // Store the step corresponding expectations
            foreach (Expectation expectation in SubStep.Expectations)
            {
                bool addExpectation = true;

                if (expectation.getKind() == acceptor.ExpectationKind.aInstantaneous)
                {
                    if (!String.IsNullOrEmpty(expectation.getCondition()))
                    {
                        Expression expression = new Parser().Expression(expectation,
                                                                        expectation.getCondition());
                        BoolValue value =
                            expression.GetExpressionValue(new InterpretationContext(expectation), null) as BoolValue;
                        if (value != null)
                        {
                            addExpectation = value.Val;
                        }
                        else
                        {
                            throw new Exception("Cannot evaluate " + expectation.getCondition() + " as a boolean value");
                        }
                    }
                }

                if (addExpectation)
                {
                    TimeLine.AddModelEvent(new Expect(expectation, runner.CurrentPriority), true);
                }
            }
        }