大家好!如何使用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