コード例 #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);
        }
コード例 #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());
        }
コード例 #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;
        }
コード例 #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()));
        }
コード例 #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.");
            }
        }