private void GenerateViewItems() { string OTemplatePath = FContext.ResolvePath("/Templates/ViewItem.t4"); Debug.WriteLine("GenerateViewItems: " + OTemplatePath); TemplateOptions OOptions = new TemplateOptions { RemoveWhitespaceStatementLines = true, AssemblyResolveDirectory = FContext.PackageDirectory }; Template OTemplate = new Template(OTemplatePath, OOptions); OTemplate.Parameters.Add("Filename", OTemplatePath); OTemplate.Parameters.Add("ItemFilename", FDocument.FullName); OTemplate.Parameters.Add("ProjectDir", ProjectDir); //TODO: Add API object to pass information back to VSPlugin (Info, Warnings, Errors) try { OTemplate.Process(); string OContent = OTemplate.InvokeTemplate(); string OOutputFile = Path.GetFullPath(Directory + "/" + FileNameWithoutExtension + OTemplate.Extension); WriteToFile(OOutputFile, OContent, OTemplate.Encoding); FOutputFiles.Add(OOutputFile); } finally { if (OTemplate.Debug) { string OSourceFile = Path.GetFullPath(Directory + "/" + FileNameWithoutExtension + ".ViewItemSource" + OTemplate.Extension); WriteToFile(OSourceFile, OTemplate.GeneratedSourceCode, Encoding.UTF8); FOutputFiles.Add(OSourceFile); } } }
private void GenerateDataItems(String databaseFilePath) { string OTemplatePath = FContext.ResolvePath("/Templates/DataItem.t4"); Debug.WriteLine("GenerateDataItems: " + OTemplatePath); TemplateOptions OOptions = new TemplateOptions { RemoveWhitespaceStatementLines = true, AssemblyResolveDirectory = FContext.PackageDirectory }; Template OTemplate = new Template(OTemplatePath, OOptions); OTemplate.Parameters.Add("Filename", OTemplatePath); OTemplate.Parameters.Add("ProjectDir", ProjectDir); OTemplate.Parameters.Add("DatabaseFilePath", databaseFilePath); try { OTemplate.Process(); string OContent = OTemplate.InvokeTemplate(); string OOutputFile = Path.GetFullPath(ProjectDir + "/" + "DataItems" + OTemplate.Extension); WriteToFile(OOutputFile, OContent, OTemplate.Encoding); FOutputFiles.Add(OOutputFile); } finally { if (OTemplate.Debug) { string OSourceFile = Path.GetFullPath(ProjectDir + "/" + "DataItems" + ".DataItemSource" + OTemplate.Extension); WriteToFile(OSourceFile, OTemplate.GeneratedSourceCode, Encoding.UTF8); } } }