public void Generate() { m_VariableInfo = new Hashtable(); m_Stack = new Stack(); m_errors = 0; try { //m_evaluator = new ExpressionEvaluator(this); m_log = new Log("startup " + DateTime.Now.ToString("MM-dd hhmmss ") + Math.Round((new Random().NextDouble() * 9000) + 1000, 0).ToString() + ".log"); ConstructInputOutputFilenames(); MakeSureDirectoryExistsFor(m_outputfilename); m_log = new Log(Path.GetFileName(m_outputfilename) + ".log"); // Check to see if only a filecopy has to be done. XmlNode copyonly = m_templateDefinition.SelectSingleNode("copyonly"); if (copyonly != null && copyonly.InnerText == "1") { // Ok copy only. No template interpretation. File.Copy(m_inputfilename, m_outputfilename, true); return; } // Check to see if generate-once is set, and output already available. XmlNode generateonce = m_templateDefinition.SelectSingleNode("generateonce"); if (generateonce != null && generateonce.InnerText == "1") { if (File.Exists(m_outputfilename)) { return; } } InitializeKeepInfo(); m_source = LoadTemplateSource(); m_target = new StringCollection(); m_log.Write(0, InterpretationStatus.Active, "Templatefile: " + m_inputfilename); m_log.Write(0, InterpretationStatus.Active, "Outputfile: " + m_outputfilename); LineProcessor lp = new LineProcessor(m_current, new Hashtable(), new Hashtable(), m_source, m_target, m_log, m_KeepInfo, m_FunctionInfo, GetCurrentTemplatename(), null); lp.AddObserver(this); m_errors = lp.Generate(); } catch (SyntaxErrorException ex) { WriteError(ex); //GenerateOutput.OutputToInstance(CurrentContext() + ex.Message); m_errors++; WriteOutputfile(m_target); return; } catch (Exception ex) { if (ex.InnerException != null && ex.InnerException is SyntaxErrorException) { WriteError(ex.InnerException as SyntaxErrorException); } else { WriteError(ex.Message); } m_errors++; WriteOutputfile(m_target); return; } WriteOutputfile(m_target); if (m_log != null) { m_log.Close(); } return; }