/// <summary> /// Create an exception that contains information about a template compilation. /// </summary> /// <param name="results">The CompilerResults from a template compilation.</param> /// <param name="template">The template that was being compiled.</param> public CompilerException(CompilerResults results, Template template) : base() { _compilerResults = results; _template = template; }
private void ExecuteRecordedTemplate(esProjectNode node) { try { if (node != null && !node.IsFolder) { Root esMeta = Create(node.Settings as esSettings); esMeta.Input = node.Input; Template template = new Template(); template.Execute(esMeta, node.Template.Header.FullFileName); } } catch (Exception ex) { errors.Add(ex); } }
public void LoadTemplates(ContextMenuStrip templateMenu, ContextMenuStrip subTemplateMenu, esSettings settings) { try { this.Settings = settings; if (this.TreeViewNodeSorter == null) { this.TreeViewNodeSorter = new NodeSorter(); InitializeComponent(); Template.SetTemplateCachePath(esSettings.TemplateCachePath); Template.SetCompilerAssemblyPath(Settings.CompilerAssemblyPath); } this.Nodes.Clear(); rootNode = this.Nodes.Add("Templates"); rootNode.ImageIndex = 2; rootNode.SelectedImageIndex = 2; rootNode.ContextMenuStrip = this.folderMenu; this.currentUIControls.Clear(); this.coll.Clear(); string[] files = Directory.GetFiles(Settings.TemplatePath, "*.est", SearchOption.AllDirectories); foreach (string file in files) { Template template = new Template(); TemplateHeader header = null; string[] nspace = null; try { // If this doesn't meet the criteria skip it and move on to the next file template.Parse(file); header = template.Header; if (header.Namespace == string.Empty) continue; nspace = header.Namespace.Split('.'); if (nspace == null || nspace.Length == 0) continue; } catch { continue; } // Okay, we have a valid template with a namespace ... TreeNode node = rootNode; TreeNode[] temp = null; // This foreach loop adds all of the folder entries based on // the namespace foreach (string entry in nspace) { temp = node.Nodes.Find(entry, true); if (temp == null || temp.Length == 0) { node = node.Nodes.Add(entry); node.Name = entry; } else { node = temp[0]; } node.ImageIndex = 2; node.SelectedImageIndex = 2; node.ContextMenuStrip = this.folderMenu; } // Now we add the final node, with the template icon and stash the Template // in the node's "Tag" property for later use when they execute it. node = node.Nodes.Add(template.Header.Title); node.Tag = template; node.ToolTipText = header.Description + " : " + header.Author + " (" + header.Version + ")" + Environment.NewLine; if (header.IsSubTemplate) { node.ImageIndex = 0; node.SelectedImageIndex = 0; node.ContextMenuStrip = subTemplateMenu; } else { node.ImageIndex = 1; node.SelectedImageIndex = 1; node.ContextMenuStrip = templateMenu; } } // Now, let's sort it so it all makes sense ... this.Sort(); } catch { } }
private bool OnExecute(TemplateDisplaySurface surface) { try { if (surface.GatherUserInput()) { Template temp = new Template(); temp.Execute(surface.esMeta, surface.Template.Header.FullFileName); surface.CacheUserInput(); this.MainWindow.ShowStatusMessage("Template '" + surface.Template.Header.Title + "' generated successfully."); } else return false; } catch (Exception ex) { this.MainWindow.ShowError(ex); return false; } return true; }
private void ExecuteRecordedTemplate(TreeNode node) { try { if (node != null && node.Tag != null) { ProjectNodeData tag = node.Tag as ProjectNodeData; Root esMeta = esMetaCreator.Create(tag.Settings as esSettings); esMeta.Input = tag.Input; Template template = new Template(); template.Execute(esMeta, tag.Template.Header.FullFileName); } } catch (Exception ex) { throw; } }
public void DisplayTemplateUI ( bool useCachedInput, Hashtable input, esSettings settings, Template template, OnTemplateExecute OnExecuteCallback, OnTemplateCancel OnCancelCallback ) { try { this.Template = template; TemplateDisplaySurface.MainWindow.OnTemplateExecuteCallback = OnExecuteCallback; TemplateDisplaySurface.MainWindow.OnTemplateCancelCallback = OnCancelCallback; TemplateDisplaySurface.MainWindow.CurrentTemplateDisplaySurface = this; if (template != null) { CurrentUIControls.Clear(); PopulateTemplateInfoCollection(); SortedList<int, esTemplateInfo> templateInfoCollection = coll.GetTemplateUI(template.Header.UserInterfaceID); if (templateInfoCollection == null || templateInfoCollection.Count == 0) { MainWindow.ShowError(new Exception("Template UI Assembly Cannot Be Located")); } this.esMeta = esMetaCreator.Create(settings); esMeta.Input["OutputPath"] = settings.OutputPath; if (useCachedInput) { if (CachedInput.ContainsKey(template.Header.UniqueID)) { Hashtable cachedInput = CachedInput[template.Header.UniqueID]; if (cachedInput != null) { foreach (string key in cachedInput.Keys) { esMeta.Input[key] = cachedInput[key]; } } } } if (input != null) { esMeta.Input = input; } MainWindow.tabControlTemplateUI.SuspendLayout(); foreach (esTemplateInfo info in templateInfoCollection.Values) { UserControl userControl = info.UserInterface.CreateInstance(esMeta, useCachedInput, MainWindow.ApplicationObject); CurrentUIControls.Add(info.TabOrder, userControl); TabPage page = new TabPage(info.TabTitle); page.Controls.Add(userControl); userControl.Dock = DockStyle.Fill; MainWindow.tabControlTemplateUI.TabPages.Add(page); MainWindow.ShowTemplateUIControl(); } MainWindow.tabControlTemplateUI.ResumeLayout(); if (CurrentUIControls.Count > 0) { MainWindow.ShowTemplateUIControl(); } } } catch (Exception ex) { MainWindow.ShowError(ex); } }