Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create files in multi projects #53

Open
ASantos007 opened this issue Sep 15, 2017 · 1 comment
Open

Create files in multi projects #53

ASantos007 opened this issue Sep 15, 2017 · 1 comment
Labels

Comments

@ASantos007
Copy link

Hello :)

I want to create multiple files through multi projects as faster as it is possible. My code (in Generator.tt) is:

`foreach (var xmlFile in xmlFiles)
{
var xml = XDocument.Load(xmlFile);

            XmlSerializer serializer = new XmlSerializer(typeof(Entity));
            Entity result = null;
            using (TextReader reader = new StringReader(xml.ToString()))
            {
                result = (Entity)serializer.Deserialize(reader);
            }

            this.entityTemplate.entity = result;
            this.entityTemplate.Output.Project = @"C:\@Work\MdaPoc\MdaPoc\MdaPoc.Entities\MdaPoc.Entities.csproj";
            this.entityTemplate.RenderToFile(String.Format(@"gen\{0}.cs", result.Name));

            this.modelTemplate.entity = result;
            this.modelTemplate.Output.Project = @"C:\@Work\MdaPoc\MdaPoc\MdaPoc.Models\MdaPoc.Models.csproj";
            this.modelTemplate.RenderToFile(String.Format(@"gen\{0}ViewModel.cs", result.Name));

            this.modelMapperTemplate.entity = result;
            this.modelMapperTemplate.Output.Project = @"C:\@Work\MdaPoc\MdaPoc\MdaPoc.MVC\MdaPoc.MVC.csproj";
            this.modelMapperTemplate.RenderToFile(String.Format(@"Models\gen\{0}Mapper.cs", result.Name));

            this.dataBaseTableTemplate.entity = result;
            this.dataBaseTableTemplate.Output.Project = @"C:\@Work\MdaPoc\MdaPoc\MdaPoc.Database\MdaPoc.Database.sqlproj";
            this.dataBaseTableTemplate.RenderToFile(String.Format(@"Tables\gen\{0}.Table.sql", result.Name));

            this.dataBaseProcedureTemplate.entity = result;
            this.dataBaseProcedureTemplate.Output.Project = @"C:\@Work\MdaPoc\MdaPoc\MdaPoc.Database\MdaPoc.Database.sqlproj";
            this.dataBaseProcedureTemplate.RenderToFile(String.Format(@"Procedures\gen\{0}.Procedure.sql", result.Name));
        }`

Are there any better way to create those all templates (entityTemplate, modelTemplate, modelMapperTemplate, dataBaseTableTemplate, dataBaseProcedureTemplate)? Create them asynchronously, for exemple?

@olegsych
Copy link
Owner

I think what you have in the example is the "right way". There is no async support in the T4Toolbox API today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants