Exemple #1
0
        public QuestionStatement(
            string identifier,
            ValueType type,
            StringLiteral label,
            Expression computationExpression = null)
        {
            if (identifier.IsNullOrWhiteSpace())
            {
                throw new ArgumentException(
                          "A non-null, non-empty identifier must be given",
                          nameof(identifier));
            }

            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }

            if (label == null)
            {
                throw new ArgumentNullException(nameof(label));
            }

            this.Identifier            = identifier;
            this.Type                  = type;
            this.Label                 = label;
            this.ComputationExpression = computationExpression;
        }
Exemple #2
0
        private void CheckWidgetTyping(Widget widget, ValueType questionType)
        {
            var expectedTypes = this.widgetTypeRules[widget.GetType()];

            if (expectedTypes.All(x => x != questionType))
            {
                this.Report.Add(new InvalidWidgetTypeMessage(
                                    widget,
                                    expectedTypes,
                                    questionType));
            }
        }
Exemple #3
0
 private void CheckWidgetTyping(
     Widget widget,
     ValueType questionType,
     ITypeAnalyzerEnvironment environment)
 {
     if (!environment.IsWidgetTypingCorrect(widget, questionType))
     {
         this.Report.Add(new InvalidWidgetTypeMessage(
                             widget,
                             environment.GetCorrectTypesForWidget(widget),
                             questionType));
     }
 }
Exemple #4
0
        public ValueTypeRule(
            ValueType valueType,
            Widget widget,
            IEnumerable <Property> properties)
            : base(widget, properties)
        {
            if (valueType == null)
            {
                throw new ArgumentNullException(nameof(valueType));
            }

            this.ValueType = valueType;
        }
Exemple #5
0
        public void AddSymbol(string name, ValueType type)
        {
            if (name.IsNullOrWhiteSpace())
            {
                throw new ArgumentNullException(nameof(name));
            }

            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }

            if (!this.symbolMappings.ContainsKey(name))
            {
                this.symbolMappings[name] = type;
            }
        }
        public bool IsWidgetTypingCorrect(Widget widget, ValueType questionType)
        {
            var expectedTypes = this.widgetTypeRules[widget.GetType()];

            return(expectedTypes.Any(x => x == questionType));
        }