/// <summary> /// process the yaml document /// </summary> /// <returns></returns> public Boolean ProcessDocument() { string baseyaml; if (!TYml2Xml.ReadHeader(FYamlFilename, out baseyaml)) { Console.WriteLine("ProcessYAML: cannot recognise type of form"); } else { new TAppSettingsManager(false); //****************** //* parsing ******* //****************** XmlDocument myDoc = TYml2Xml.CreateXmlDocument(); TCodeStorage codeStorage = new TCodeStorage(myDoc, FXmlNodes); TParseYAMLFormsDefinition yamlParser = new TParseYAMLFormsDefinition(ref codeStorage); // should not need to be specific to special forms yamlParser.LoadRecursively(FYamlFilename, FSelectedLocalisation); // for debugging purposes, we can write the xml file that has been parsed from the yaml file // codeStorage.FXmlDocument.Save(FYamlFilename + ".xml"); //**************** //* output ******* //**************** TFormWriter writer = null; // get the appropriate derived class from IFormWriter (e.g. TFrmReportWriter) XmlNode rootNode = (XmlNode)yamlParser.FCodeStorage.FXmlNodes[TParseYAMLFormsDefinition.ROOTNODEYML]; string formType = TYml2Xml.GetAttribute(rootNode, "FormType"); if (formType == "abstract") { Console.WriteLine("Ignore yaml file because it has the formtype abstract: " + FYamlFilename); return(true); } // the Template attribute is also quite important, because it determines which code is written // FormType is mainly important for the difference of the controls of reports and normal screens writer = GetWriter(formType); if (writer == null) { Console.WriteLine("cannot find writer for {0}", formType); return(false); } string templateDir = TAppSettingsManager.GetValue("TemplateDir", true); string template = TYml2Xml.GetAttribute(rootNode, "Template"); if (template.Length > 0) { template = templateDir + Path.DirectorySeparatorChar + template + writer.CodeFileExtension; } string destinationFile = writer.CalculateDestinationFilename(FYamlFilename); string manualCodeFile = writer.CalculateManualCodeFilename(FYamlFilename); // need to know the path to the manual code file in order to call manual functions which would not be called if they do not exist codeStorage.ManualCodeFilename = manualCodeFile; writer.CreateCode(codeStorage, FYamlFilename, template); writer.CreateResourceFile(FYamlFilename, templateDir); writer.CreateDesignerFile(FYamlFilename, rootNode, templateDir); return(writer.WriteFile(destinationFile)); } return(false); }