コード例 #1
0
        public object Visit(ComputedQuestion computedQuestion)
        {
            object value = computedQuestion.Expression.Accept <object>(this);

            this._valueMem.Add(computedQuestion.Id, value);
            return(value);
        }
コード例 #2
0
ファイル: AstBuilderVisitor.cs プロジェクト: diepvriezer/ql
        public override AstNode VisitComputedQuestion([NotNull] QLParser.ComputedQuestionContext context)
        {
            var question = new ComputedQuestion
            {
                Id         = context.ID().GetText(),
                Text       = StripQuotes(context.QUOTED_STRING().GetText()),
                Type       = context.type().Accept(this) as BaseType,
                Expression = context.expr().Accept(this) as Expression
            };

            return(question);
        }
コード例 #3
0
 public override void Visit(ComputedQuestion question)
 {
     if (_currentCycle.Contains(question))
     {
         _messages.AddError(question.Id + " depends on itself. Cycle:" + string.Join(" -> ", _currentCycle.Select(q => q.Id)));
     }
     else
     {
         _currentCycle.AddLast(question);
         base.Visit(question);
         Debug.Assert(_currentCycle.Last.Value.Equals(question));
         _currentCycle.RemoveLast();
     }
 }
コード例 #4
0
ファイル: Processor.cs プロジェクト: vdweegen/myriad-ql
        private void Process(ComputedQuestion node, Func <ExpressionEvaluator, bool> visibilityCondition)
        {
            Process(node.Question, visibilityCondition);
            var question = Questions.Find((q) => q.Identifier == node.Question.Identifier);

            Rules.Add(
                (evaluator) =>
            {
                if (visibilityCondition(evaluator))
                {
                    question.SetValue(evaluator.Evaluate(node.Expression));
                }
            });
        }
コード例 #5
0
        public bool Visit(ComputedQuestion computedQuestion)
        {
            bool result = true;

            result &= this.TryDeclare(computedQuestion.Id, computedQuestion.Type, computedQuestion.Line);
            result &= computedQuestion.Expression.Accept <bool>(this);
            if (!computedQuestion.Type.IsCompatible(computedQuestion.Expression.GetType(this._typeMem)))
            {
                this._errorList.Add(new TypeMismatchError(computedQuestion.Type,
                                                          computedQuestion.Expression.GetType(this._typeMem), computedQuestion.Line));
                result = false;
            }
            return(result);
        }
コード例 #6
0
ファイル: CreateBindings.cs プロジェクト: diepvriezer/ql
 public override IList <UIBinding> Visit(ComputedQuestion node)
 {
     if (IsUnique(node))
     {
         var binding = new UIBinding
         {
             QuestionId = node.Id,
             Label      = LabelForQuestion(node),
             Control    = WidgetFactory.Visit((dynamic)node.Type)
         };
         binding.Control.CanReceiveValue = true;
         Bindings.Add(binding);
     }
     return(Bindings);
 }
コード例 #7
0
        public UIElement Visit(ComputedQuestion question)
        {
            QuestionControl questionControl = new QuestionControl(question.Id);

            questionControl.AddQuestionLabel(question.Text);
            Control ioControl = question.Type.Accept <UIElement>(this) as Control;

            // create binding to control (writes value of questionControl to value of ioControl)
            Binding bind = new Binding("MyValue");

            bind.Source                = questionControl;
            bind.Converter             = question.Type.Accept <IValueConverter>(new ConverterVisitor()) as IValueConverter;
            bind.Mode                  = BindingMode.OneWay;
            bind.FallbackValue         = "";
            bind.UpdateSourceTrigger   = UpdateSourceTrigger.PropertyChanged;
            bind.NotifyOnTargetUpdated = true;
            ioControl.SetBinding(question.Type.Accept <DependencyProperty>(new DependencyPropertyVisitor()) as DependencyProperty, bind);
            questionControl.AddIOControl(ioControl, false);
            this._computedList.Add(new Tuple <QSExpression, UIElement>(question.Expression, questionControl));
            return(questionControl);
        }
コード例 #8
0
 public void Visit(ComputedQuestion question) => _qlQuestions.Add(question.Id);
コード例 #9
0
 public override void Visit(ComputedQuestion question)
 {
     CheckDuplicateQuestion(question);
     AddLabelQuestion(question);
 }
コード例 #10
0
ファイル: DefaultVisitor.cs プロジェクト: diepvriezer/ql
 public virtual T Visit(ComputedQuestion node)
 {
     node.Expression.Accept(this);
     return(node.Type.Accept(this));
 }
コード例 #11
0
 public void Visit(ComputedQuestion question) => _questionTypes.Add(question.Id, question.Type);
コード例 #12
0
 private void Analyze(ComputedQuestion node)
 {
     Analyze((dynamic)node.Question);
 }
コード例 #13
0
 public override void Visit(ComputedQuestion question)
 {
     base.Visit(question);
     TypeCheckQuestion(question);
 }
コード例 #14
0
 public override QuestionInventoryResult Visit(ComputedQuestion node)
 {
     _result.Questions.Add(node);
     node.Expression.Accept(this);
     return(_result);
 }
コード例 #15
0
        public override string Visit(ComputedQuestion node)
        {
            var fmt = $"{node.Id}: \"{node.Text}\" {node.Type.Accept(this)}({node.Expression.Accept(this)})\n";

            return(fmt);
        }
コード例 #16
0
 public void Visit(ComputedQuestion question)
 {
     _answers[question.Id] = QLExpressionEvaluator.Evaluate(question.Computation, GetAnswer);
     AddQuestion(question, true);
 }