void Exec() { //var arguments = new Dictionary<string, PropertyData>(); //arguments.Add("ClassName", new PropertyData("MyClass", typeof(string))); //arguments.Add("TargetNamespace", new PropertyData("MyNameSpace", typeof(string))); //arguments.Add("HelloMessage", new PropertyData("HelloMessage", typeof(string))); //// Initialize GAX template host //string currentDirectory = Directory.GetCurrentDirectory(); //TemplateHost host = new TemplateHost(currentDirectory, arguments); //host.TemplateFile = Path.Combine(currentDirectory, "ServiceTemplate.tt"); // Transform template //string template = File.ReadAllText(host.TemplateFile); //ITextTemplatingEngine engine = new Engine(); //string output = engine.ProcessTemplate(template, host); //// Save output //string outputFile = Path.ChangeExtension(host.TemplateFile, ".txt"); //File.WriteAllText(outputFile, output); //TextTemplate tt = new TextTemplate(); //tt.Source = "... code here, check example file above ..."; //tt.Compile(); //String output = tt.Generate(singleObjectParameter); CustomCmdLineHost host = new CustomCmdLineHost(); host.TemplateFileValue = templateFileName; Engine engine = new Engine(); //read the text template string input = File.ReadAllText(templateFileName); //transform the text template string output = engine.ProcessTemplate(input, host); string outputFileName = Path.GetFileNameWithoutExtension(templateFileName); outputFileName = Path.Combine(Path.GetDirectoryName(templateFileName), outputFileName); outputFileName = outputFileName + "1" + host.FileExtension; }
void Exec() { //var arguments = new Dictionary<string, PropertyData>(); //arguments.Add("ClassName", new PropertyData("MyClass", typeof(string))); //arguments.Add("TargetNamespace", new PropertyData("MyNameSpace", typeof(string))); //arguments.Add("HelloMessage", new PropertyData("HelloMessage", typeof(string))); //// Initialize GAX template host //string currentDirectory = Directory.GetCurrentDirectory(); //TemplateHost host = new TemplateHost(currentDirectory, arguments); //host.TemplateFile = Path.Combine(currentDirectory, "ServiceTemplate.tt"); // Transform template //string template = File.ReadAllText(host.TemplateFile); //ITextTemplatingEngine engine = new Engine(); //string output = engine.ProcessTemplate(template, host); //// Save output //string outputFile = Path.ChangeExtension(host.TemplateFile, ".txt"); //File.WriteAllText(outputFile, output); //TextTemplate tt = new TextTemplate(); //tt.Source = "... code here, check example file above ..."; //tt.Compile(); //String output = tt.Generate(singleObjectParameter); CustomCmdLineHost host = new CustomCmdLineHost(); host.TemplateFileValue = templateFileName; Engine engine = new Engine(); //read the text template string input = File.ReadAllText(templateFileName); //transform the text template string output = engine.ProcessTemplate(input, host); string outputFileName = Path.GetFileNameWithoutExtension(templateFileName); outputFileName = Path.Combine(Path.GetDirectoryName(templateFileName), outputFileName); outputFileName = outputFileName + "1" + host.FileExtension; }