大家好!如何使用XML使用T4生成Visual Studio项目?
在早期就可以使用代码-DOM,我才知道,使用T4比代码-DOM容易得多。我已经阅读了很多文章 ,但我仍然没有编写符合我的要求的代码。
我需要根据自动生成的XML文档生成代码[我可以根据我的要求生成XML文档]。
看起来像这样:
<?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创建项目,但我需要更多的东西来生成代码,如上面的'XML'样本。
在这方面的任何帮助将不胜感激。
非常感谢!我正在关注你的博客。 – 2011-12-20 18:19:15
我添加了您的案例精确演示:https://github.com/abstractiondev/DemoSOCase8552428ABS – Kallex 2011-12-22 22:22:27
真的很可观,非常感谢。我需要分叉还是克隆它?祝你MERRY X'MASS :) – 2011-12-23 14:13:56