小编Tob*_*son的帖子

如何将字符串参数传递给t4模板

嗨,我想找到一种方法将普通字符串作为参数传递给文本模板.

这是我的模板代码,如果有人可以告诉我在c#中需要写什么来传递我的参数并创建类文件.这将非常有帮助,谢谢.

<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ output extension=".cs" #>
<#@ assembly name="System.Xml" #>
<#@ assembly name="EnvDTE" #>
<#@ import namespace="System.Xml" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ parameter name="namespacename" type="System.String" #>
<#@ parameter name="classname" type="System.String" #>
<#
this.OutputInfo.File(this.classname);
#>
namespace <#= this.namespacename #>
{
    using System;
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Xml; 

    /// <summary>
    /// This class describes the data layer related to <#= this.classname #>.
    /// </summary>
    /// <history>
    ///   <change author=`Auto Generated` date=<#= DateTime.Now.ToString("dd/MM/yyyy") #>>Original Version</change> …
Run Code Online (Sandbox Code Playgroud)

c# string parameters t4 texttemplate

15
推荐指数
2
解决办法
1万
查看次数

标签 统计

c# ×1

parameters ×1

string ×1

t4 ×1

texttemplate ×1