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)))
);
}
});
}
public void AddNewTemplateEditor(RazorTemplateViewModel template, bool current = true) { Log.Debug("Adding new template editor (current: {0})...", current); template.AutoExecute = AutoExecute; template.AutoSave = AutoExecute; template.Messages = Messages; template.Executing += OnAutoSave; Templates.Add(template); if (!string.IsNullOrWhiteSpace(template.Filename)) { RecentFiles.Add(template.Filename); } if (current) { Log.Debug("Setting as current template"); CurrentTemplate = template; } template.Execute(); Log.Info("Added new template editor"); }