Seal.Forms.TemplateTextEditorForm.checkSyntaxToolStripButton_Click C# (CSharp) Méthode

checkSyntaxToolStripButton_Click() private méthode

private checkSyntaxToolStripButton_Click ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
Résultat void
        private void checkSyntaxToolStripButton_Click(object sender, EventArgs e)
        {
            string error = "";
            try
            {
                string script = textBox.Text;
                if (!string.IsNullOrEmpty(TextToAddForCheck)) script += "\r\n" + TextToAddForCheck;
                Helper.CompileRazor(script, TypeForCheckSyntax, "acachename");
            }
            catch (TemplateCompilationException ex)
            {
                error = string.Format("Compilation error:\r\n{0}", Helper.GetExceptionMessage(ex));
                if (ex.InnerException != null) error += "\r\n" + ex.InnerException.Message;
                if (error.ToLower().Contains("are you missing an assembly reference")) error += string.Format("\r\nNote that you can add assemblies to load by copying your .dll files in the Assemblies Repository folder:'{0}'", Repository.Instance.AssembliesFolder);
            }
            catch (Exception ex)
            {
                error = string.Format("Compilation error:\r\n{0}", ex.Message);
                if (ex.InnerException != null) error += "\r\n" + ex.InnerException.Message;
            }

            if (!string.IsNullOrEmpty(error))
            {
                toolStripStatusLabel.Text = "Compilation error";
                toolStripStatusLabel.Image = global::Seal.Properties.Resources.error2;

                MessageBox.Show(error, "Check syntax", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                toolStripStatusLabel.Text = "Razor Syntax is OK";
                toolStripStatusLabel.Image = global::Seal.Properties.Resources.checkedGreen;
            }
        }