Example #1
0
        public Widget Visit(FormStatement statement, GuiEnvironment environment)
        {
            var controls = new List <Widget>(statement.Statements.Count());

            foreach (var s in statement.Statements)
            {
                var control = s.Accept(this, environment);
                controls.Add(control);
            }

            var form = new FormWidget(statement, environment, controls);

            return(form);
        }
Example #2
0
        public void Analyze_ShouldDetectDuplicateQuestionLabels()
        {
            var duplicateQuestionForm = new FormStatement("DuplicateQuestionForm", new List <Statement>
            {
                new QuestionStatement("duplicate", new StringValueType(), new StringLiteral("Sample")),
                new QuestionStatement("duplicate1", new StringValueType(), new StringLiteral("Sample")),
            });

            var questionAnalyzer = new QuestionAnalyzer();

            questionAnalyzer.Analyze(duplicateQuestionForm);
            Assert.NotEmpty(questionAnalyzer.Report.Warnings);
            Assert.Equal(1, questionAnalyzer.Report.Warnings.Count());
            Assert.IsType <DuplicateQuestionLabelMessage>(questionAnalyzer.Report.Warnings.FirstOrDefault());
        }
Example #3
0
        public void RunApplication(FormStatement structureNode)
        {
            var interpreter = new Interpreter();
            var env         = new GuiEnvironment();
            var form        = interpreter.Visit(structureNode, env);
            var window      = new Window();
            var view        = new ListView();

            foreach (var control in form.Controls)
            {
                view.Items.Add(control);
            }

            window.Content = view;
            var application = new Application();

            application.Run(window);
        }
Example #4
0
        public ICheckerReport Check(FormStatement structureNode, StyleSheet styleNode)
        {
            if (structureNode == null)
            {
                throw new ArgumentNullException(nameof(structureNode));
            }

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

            var collector = new QuestionCollector();

            collector.Collect(structureNode);
            var finalReport = new CheckerReport();

            this.analyzers.ForEach(x => x.Analyze(styleNode, collector.Mappings));
            finalReport.Add(this.analyzers.SelectMany(x => x.Report.AllMessages));

            return(finalReport);
        }
Example #5
0
 public virtual TResult Visit(FormStatement statement, TEnvironment environment)
 {
     statement.Statements.ForEach(x => x.Accept(this, environment));
     return(default(TResult));
 }
Example #6
0
 public void Collect(FormStatement root)
 {
     this.Visit(root, new QuestionVisitorTypeEnvironment());
 }
Example #7
0
        public VoidValueType Visit(FormStatement statement, ITypeEnvironment environment)
        {
            statement.Statements.ForEach(x => x.Accept(this, environment));

            return(new VoidValueType());
        }
Example #8
0
 public void Analyze(FormStatement root)
 {
     this.Visit(root, new VisitorTypeEnvironment());
 }
Example #9
0
 public void RunApplication(FormStatement structureNode, StyleSheet styleNode)
 {
     Console.WriteLine("Not implemented.");
 }