public object Visit(ComputedQuestion computedQuestion) { object value = computedQuestion.Expression.Accept <object>(this); this._valueMem.Add(computedQuestion.Id, value); return(value); }
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); }
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(); } }
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)); } }); }
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); }
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); }
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); }
public void Visit(ComputedQuestion question) => _qlQuestions.Add(question.Id);
public override void Visit(ComputedQuestion question) { CheckDuplicateQuestion(question); AddLabelQuestion(question); }
public virtual T Visit(ComputedQuestion node) { node.Expression.Accept(this); return(node.Type.Accept(this)); }
public void Visit(ComputedQuestion question) => _questionTypes.Add(question.Id, question.Type);
private void Analyze(ComputedQuestion node) { Analyze((dynamic)node.Question); }
public override void Visit(ComputedQuestion question) { base.Visit(question); TypeCheckQuestion(question); }
public override QuestionInventoryResult Visit(ComputedQuestion node) { _result.Questions.Add(node); node.Expression.Accept(this); return(_result); }
public override string Visit(ComputedQuestion node) { var fmt = $"{node.Id}: \"{node.Text}\" {node.Type.Accept(this)}({node.Expression.Accept(this)})\n"; return(fmt); }
public void Visit(ComputedQuestion question) { _answers[question.Id] = QLExpressionEvaluator.Evaluate(question.Computation, GetAnswer); AddQuestion(question, true); }