如何生成Visual Studio项目使用T4使用XML? [英] How to generate Visual Studio Project using T4 using XML?

查看:196
本文介绍了如何生成Visual Studio项目使用T4使用XML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

在早期的日子里,可以使用的 code-大教堂的,我才知道,使用 T4 比code-大教堂容易得多。我已经经历了很多文章了 但我仍然不是在一个情况下,起草出了code,这将满足我的要求。

In earlier days it is possible using Code-Dom, I came to know that using T4 is much easier than Code-Dom. I have gone through many articles but still I am not in a situation to draft-out the code which will meet my requirements.

我需要生成一个自动生成的XML文档的基础[我能够生成XML文档按我的要求的。

I need to generate a code on the basis of an auto-generated XML document [I am able to generate the XML document as per my requirements].

这似乎是这样的:

    <?xml version="1.0" encoding="utf-8" ?>
<GeneratedSolution Name ="name of Solution">
<GeneratedProject ID="RepoProject" Name ="name of Project" MajorVersion="1" MinorVersion="0" CopyRight="GeneratedProject company" Language="C#" OutExtension="cs">
<Compiler path = "../path/compilername" Build="silent" ExternalBuildTool="NAnt" />

<GeneratedRepository Name ="name of Repository Class" Description="This is generated Repository class would be used for overall-application" TemplateRefence ="../path/repository.tt">
<Operation Name = "Operation1" Description = "This is operation1 of Repository class">
<operationID>1</operationID>
</Operation>
<Operation Name = "Operation2" Description = "This is operation2 of Repository class">
<operationID>2</operationID>
</Operation>
</GeneratedRepository>

</GeneratedProject>

<GeneratedProject ID="BusinessProject" Name ="name of Project" MajorVersion="1" MinorVersion="0" CopyRight="GeneratedProject company">

<GeneratedBusiness Name ="name of Business Class" Description="This is generated Business class would be used for overall-application" TemplateRefence ="../path/business.tt">
<Operation Name = "Operation1" Description = "This is operation1 of Business class">
<operationID>1</operationID>
</Operation>
<Operation Name = "Operation2" Description = "This is operation2 of Business class">
<operationID>2</operationID>
</Operation>
</GeneratedBusiness>

</GeneratedProject>

<GeneratedProject ID="UIProject" Name ="name of Project" MajorVersion="1" MinorVersion="0" CopyRight="GeneratedProject company">

<GeneratedUI Name ="name of UI Class" Description="This is generated UI class would be used for overall-application" TemplateRefence ="../path/UI.tt">
<Operation Name = "Operation1" Description = "This is operation1 of UI class">
<operationID>1</operationID>
</Operation>
<Operation Name = "Operation2" Description = "This is operation2 of UI class">
<operationID>2</operationID>
</Operation>
</GeneratedUI>

</GeneratedProject>

</GeneratedSolution>

没有。类,项目可能单个解决方案中各不相同。 我读了一些文章,其中提供了一个想法,以创建XML的项目,但我需要更多的东西来产生code按上面的XML的样本。

No. of classes, projects may vary within single solution. I read some articles which provide an idea to create project from xml but I need something more to generate code as per above sample of 'XML'.

任何帮助在这方面将更加AP preciated。

Any help in this regards will be much appreciated.

推荐答案

免责声明 - 我们的发现方法,但完全开放源代码的

Disclaimer - our discovered methodology but completely open source.

在链接的博客,我们所描述的方式您的发电输出的基础上大力定义输入数据控制(XML模式的形式)。我们得到了一个提过T4团队的博客 - 强调的是,它是标准的T4仅使用:

On the linked blog we are describing a way to control your generation output based on strongly-defined input data (in XML schema form). We got a mention through T4 Team's Blog - to underline that it is standard T4 use only:

<一个href="http://blogs.msdn.com/b/t4/archive/2011/11/30/some-nice-new-getting-started-with-t4-videos.aspx" rel="nofollow">http://blogs.msdn.com/b/t4/archive/2011/11/30/some-nice-new-getting-started-with-t4-videos.aspx

链接到博客的视频可以直接通过到达:

The link to blog's videos can be reached directly through:

HTTP://abstractiondev.word$p$pss.com/demo-videos /

有关T4经验丰富的用户的视频已经从头开始,并说明用途。我通过简单的下载增加的基本结构过程(git的用户也可以通过蠢货的https:// github上。 COM / abstractiondev / absInitializer )。

For T4 seasoned users the videos already start from scratch and explain the usage. I am in process of adding the basic structure through simple download (for git users it's available through git at https://github.com/abstractiondev/absInitializer).

如果您需要任何帮助,只是给我发一个通过该博客的联系信息,我会抽象为你,如果你喜欢我们的方法途径,并希望利用它来进行你的生成。

If you need any assistance on that, just drop me a line through the contact info on that blog and I'll "abstract" it for you, if you like our methodology approach and want to use that for your generation.

这篇关于如何生成Visual Studio项目使用T4使用XML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆