/// <summary> /// Performs all actions /// <param name="tree">The tree on which to operate</param> /// </summary> public void Perform(SourceFile tree) { if (tree == null) { return; } tree.Accept(this); var groups = new List <string>(); foreach (var action in this) { if (action.Group != null && groups.Contains(action.Group)) { continue; } if (BeforeAction != null) { BeforeAction(this, (EventArgs)action); } action.Execute(); if (AfterAction != null) { AfterAction(this, (EventArgs)action); } if (action.Group != null) { groups.Add(action.Group); } } }
protected void openFileDialog1_FileOk(object sender, System.ComponentModel.CancelEventArgs e) { string fileName = openFileDialog1.FileName; this.textBox1.Text = new FileInfo(fileName).Name; StreamReader reader = new StreamReader(fileName); try { SourceFile source = new SourceFile(fileName); ITokenVisitor visitor = new ColorTokenVisitor(this.richTextBox1); source.Accept(visitor); } finally { reader.Close(); } }
/// <summary> /// Performs all actions /// <param name="tree">The tree on which to operate</param> /// </summary> public void Perform(SourceFile tree) { if (tree == null) { return; } tree.Accept(this); var groups = new List <string>(); foreach (var action in this) { try { if (action.Group != null && groups.Contains(action.Group)) { continue; } if (BeforeAction != null) { BeforeAction(this, (EventArgs)action); } action.Execute(); if (AfterAction != null) { AfterAction(this, (EventArgs)action); } if (action.Group != null) { groups.Add(action.Group); } } catch (Exception e) { Diagnostic diag = new Diagnostic(MessageCode.ImplementationError, 0, 0, 0, e.Message + "\n" + e.StackTrace); Generator.AddDiagnostic(diag); } } }