RazorPad.ViewModels.RazorTemplateViewModel.Execute C# (CSharp) Method

Execute() public method

public Execute ( ) : void
return void
        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)))
                    );
                }
            });
        }

Usage Example

Exemplo n.º 1
0
        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");
        }
All Usage Examples Of RazorPad.ViewModels.RazorTemplateViewModel::Execute