Ejemplo n.º 1
0
        public void ShouldSupportFunctions()
        {
            var document = LoadDocument("AcceptanceTests.Functions.cshtml");

            var results = _templateCompiler.Execute(document);

            string output = LoadResource("AcceptanceTests.Functions.cshtml.output");

            Assert.AreEqual(output, results.Trim());
        }
Ejemplo n.º 2
0
        public void Execute()
        {
            _executing.SafeInvoke(sender: this);

            new TaskFactory().StartNew(() =>
            {
                try
                {
                    TemplateCompiler.CompilationParameters.SetReferencedAssemblies(AssemblyReferences);
                    Parse();
                    ExecutedTemplateOutput = TemplateCompiler.Execute(_document);
                }
                catch (CodeGenerationException ex)
                {
                    Dispatcher.Invoke(new Action(() => {
                        foreach (RazorError error in ex.GeneratorResults.ParserErrors)
                        {
                            Errors.Add(new RazorPadRazorError(error));
                        }
                    }));
                }
                catch (CompilationException ex)
                {
                    Dispatcher.Invoke(new Action(() => {
                        foreach (CompilerError error in ex.CompilerResults.Errors)
                        {
                            Errors.Add(new RazorPadCompilerError(error));
                        }
                    }));
                }
                catch (Exception ex)
                {
                    Dispatcher.Invoke(new Action(() =>
                                                 Errors.Add(new RazorPadError(ex)))
                                      );
                }
            });
        }