Thanks for the info, it helped a lot but i have a problem when I execute the template:
string tempfile = Path.GetTempFileName(); string rutaTemplate = ""; TypeResolutionService typeResService = (TypeResolutionService)GetService(typeof(ITypeResolutionService)); Dictionary<string, PropertyData> dict = new Dictionary<string, PropertyData>(); dict.Add("ClassName", new PropertyData(modulo, typeof(string))); dict.Add("ClassNameMin", new PropertyData(modulo.ToLower(), typeof(string))); dict.Add("Namespace", new PropertyData("Tactics", typeof(string))); dict.Add("Project", new PropertyData(projectPresenter, typeof(string))); dict.Add("Suf", new PropertyData(sufijo, typeof(string))); rutaTemplate = @"C:\Documents and Settings\Computer\Desktop\Codigo\TacticsConferenceSite\TacticsConferenceSite\Templates\Text\CrearModulePresenter.cs.t4"; TemplateHost host = new TemplateHost(Directory.GetCurrentDirectory(), dict); host.TemplateFile = rutaTemplate;
ITextTemplatingEngine engine = new Engine(); string template = File.ReadAllText(host.TemplateFile); string contenidoABMPresent = engine.ProcessTemplate(template, host);
using (StreamWriter sw = new StreamWriter(tempfile, false)) { sw.WriteLine(contenidoABMPresent); } EnvDTE.ProjectItem item = CreateDirectoryPresenter(); item.ProjectItems.AddFromTemplate(tempfile, fileABMPresenter); File.Delete(tempfile);
When I execute engine.ProcessTemplate the HOST parameter is not properly set, i get an exception "Entry Point Not Found". Which directory is it supposed to look in the first argument of new TemplateHost?
Thanks again,
Martin |