private static void Main(string[] args) { string projectfile = "proj.rgf"; if (args.Length > 0) { projectfile = args[0]; } string allMEssages = string.Empty; if (File.Exists(projectfile)) { RgProject _rgProject = new RgProject(); _rgProject = RgProject.Load("proj.rgf"); RazorCore rc = new RazorCore(); foreach (var map in _rgProject.RgMappings) { allMEssages = rc.Genetate(map, _rgProject); } } else { allMEssages = "File : proj.rgf could not be found."; } Console.WriteLine(allMEssages); Console.WriteLine("Complete"); Console.ReadKey(); }
private void generateToolStripMenuItem_Click(object sender, EventArgs e) { RazorCore rc = new RazorCore(); string allMEssages = string.Empty; foreach (var map in _rgProject.RgMappings) { allMEssages = rc.Genetate(map, _rgProject); } MessageBox.Show(allMEssages); }
/// <summary> /// context menu /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void generateToolStripMenuItem1_Click(object sender, EventArgs e) { if (TreeTables.SelectedNode.Tag.GetType() == typeof(Table)) { Table t = (Table)TreeTables.SelectedNode.Tag; var map = (from RgMapping v in _rgProject.RgMappings where v.TableName == t.Name select v).FirstOrDefault(); if (map == null) { MessageBox.Show(string.Format("Map for {0} not found.\nTry saving data first.", t.Name)) ; return; } RazorCore rc = new RazorCore(); string message = rc.Genetate(map, _rgProject); MessageBox.Show(message); } else if (TreeTables.SelectedNode.Tag.GetType() == typeof(Template)) { string gen = GenerateSingle(); MessageBox.Show(gen); } //foreach (TreeNode tplt in TreeTemplates.SelectedNode.Nodes) //{ // var template = (Template)tplt.Tag; //} //string filepath = Path.GetDirectoryName(FileHelper.GetFullTemplatePath(((Template)(TreeTemplates.SelectedNode.Tag)).TemplatePath)); //foreach (var map in _rgProject.RgMappings) //{ // foreach (var template in map.TemplateRelativePaths) // { // string templtFile = Path.Combine(_rgProject.TemplateRootFolder, template.Remove(0, 1)); // string message = rc.GenerateIt(map.TableName, templtFile, _rgProject.SolutionRootFolder, _rgProject.Alltables.Tables); // MessageBox.Show(message); // } //} }
private string GenerateSingle() { Template tplt = (Template)TreeTables.SelectedNode.Tag; Table t = (Table)TreeTables.SelectedNode.Parent.Tag; var map = (from RgMapping v in _rgProject.RgMappings where v.TableName == t.Name select v).FirstOrDefault(); if (map == null) { return(string.Format("Map for {0} not found.\nTry saving data.", t.Name)); } var rc = new RazorCore(); string templtFile = Path.Combine(_rgProject.TemplateRootFolder, tplt.TemplatePath.Remove(0, 1)); string message = rc.GenerateIt(map.TableName, templtFile, _rgProject.SolutionRootFolder, _rgProject.Alltables.Tables); return(message); }
private void TreeTables_AfterSelect(object sender, TreeViewEventArgs e) { if (TreeTables.SelectedNode.Tag.GetType() == typeof(Template)) { Template tplt = (Template)TreeTables.SelectedNode.Tag; Table t = (Table)TreeTables.SelectedNode.Parent.Tag; var map = (from RgMapping v in _rgProject.RgMappings where v.TableName == t.Name select v).FirstOrDefault(); if (map == null) { MessageBox.Show(string.Format("Map for {0} not found.\n Try saving data first.", t.Name)); return; } var rc = new RazorCore(); string templtFile = FileHelper.GetFullPath(templateRoot, tplt.TemplatePath); string message = rc.GenerateItString(map.TableName, templtFile, _rgProject.SolutionRootFolder, _rgProject.Alltables.Tables); mapCodeFastColoredTextBox.Language = Language.CSharp; mapCodeFastColoredTextBox.Text = message; } }