private void formatButton_Click(object sender, EventArgs e) { RuleSet ruleSet; if (((KeyValuePair<string, RuleSet>) this.languageComboBox.SelectedItem).Key != this.languageComboBox.Text) { ruleSet = RuleSet.LoadFromFile(this.languageComboBox.Text); } else { ruleSet = this.languageComboBox.SelectedValue as RuleSet; } IAtTemplate template; if (((KeyValuePair<string, IAtTemplate>) this.templateComboBox.SelectedItem).Key != this.templateComboBox.Text) { template = new AtTemplateProxy( this.templateComboBox.Text, Encoding.UTF8, this.v35Checkbox.Checked ? "v3.5" : "v2.0"); } else { template = this.templateComboBox.SelectedValue as IAtTemplate; } string formattedCode = FormatCode(ruleSet, template, inputTextBox.Text); this.outputTextBox.Text = formattedCode; this.previewBrowser.DocumentText = formattedCode; }
static void Main(string[] args) { using (IAtTemplate template = new AtTemplateProxy("recursive_list.txt", null, null)) { template.Parse(); template.Context = new object[] { 10 }; Console.WriteLine(template.Render()); } Console.ReadKey(); }
public void AtTemplateProxy() { string generatedFile = null; using (IAtTemplate template = new AtTemplateProxy("1+1")) { template.Debug = true; template.Parse(); template.Render(); generatedFile = template.GeneratedAssemblyPath; } Assert.IsFalse(File.Exists(generatedFile)); }
public void ProxyNewInstance() { using (IAtTemplate template = new AtTemplateProxy( @"@global int number = 1; @end_global @(number++)")) { template.Parse(); Assert.AreEqual("1\r\n", template.Render()); IAtTemplateInstance instance1 = template.NewInstance(); Assert.AreEqual("1\r\n", instance1.Render()); } }