Esempio n. 1
0
        public ValidationReport Validate(StyleSheet styleSheet, QuestionForm form)
        {
            if (styleSheet == null)
            {
                throw new ArgumentNullException("styleSheet");
            }
            if (form == null)
            {
                throw new ArgumentNullException("form");
            }

            var validators = new List <ASTChecker>
            {
                new QuestionReferencingChecker(form.GetAllQuestions()),
                new StyleAttributeChecker(),
                new WidgetTypeChecker(form.GetAllQuestions())
            };

            var report = new ValidationReport();

            foreach (var validator in validators)
            {
                validator.Validate(styleSheet, report);
            }

            return(report);
        }
Esempio n. 2
0
        public QuestionStyleCollection GetQuestionStyles(StyleSheet styleSheet, QuestionForm form)
        {
            if (styleSheet == null) { throw new ArgumentNullException("styleSheet"); }
            if (form == null) { throw new ArgumentNullException("form"); }

            var styleEvaluator = new QuestionStyleEvaluator();

            return styleEvaluator.GetQuestionStyles(styleSheet, form.GetAllQuestions());
        }
Esempio n. 3
0
        public ValidationReport Validate(StyleSheet styleSheet, QuestionForm form)
        {
            if (styleSheet == null) { throw new ArgumentNullException("styleSheet"); }
            if (form == null) { throw new ArgumentNullException("form"); }

            var validators = new List<ASTChecker>
            {
                new QuestionReferencingChecker(form.GetAllQuestions()),
                new StyleAttributeChecker(),
                new WidgetTypeChecker(form.GetAllQuestions())
            };

            var report = new ValidationReport();

            foreach (var validator in validators)
            {
                validator.Validate(styleSheet, report);
            }

            return report;
        }
Esempio n. 4
0
        public QuestionStyleCollection GetQuestionStyles(StyleSheet styleSheet, QuestionForm form)
        {
            if (styleSheet == null)
            {
                throw new ArgumentNullException("styleSheet");
            }
            if (form == null)
            {
                throw new ArgumentNullException("form");
            }

            var styleEvaluator = new QuestionStyleEvaluator();

            return(styleEvaluator.GetQuestionStyles(styleSheet, form.GetAllQuestions()));
        }
Esempio n. 5
0
        public override Control VisitQuestionReference(QuestionReference questionRef)
        {
            var question = _questionForm.GetAllQuestions().Where(q => q.Name == questionRef.Name).SingleOrDefault();

            if (question != null)
            {
                StyleSet questionStyles = _questionStyles.GetStyleSet(question.Name);

                QuestionWidget questionWidget = (QuestionWidget)questionStyles.WidgetStyle.CreateWidgetControl(new WidgetFactory(question));

                questionWidget.ApplyStyles(questionStyles);

                _questionWidgets.Add(questionWidget);

                return(questionWidget);
            }
            else
            {
                throw new ApplicationException("Question not found in the questionnaire AST.");
            }
        }