您好我正在尝试找到一种将普通字符串作为参数传递给文本模板的方法。
这是我的模板代码,如果有人能告诉我我需要用 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>
/// </history>
public partial class <#= this.classname #> : DataObject
{
#region constructor
/// <summary>
/// A constructor which allows the base constructor to attempt to extract the connection string from the config file.
/// </summary>
public <#= this.classname #>() : base() {}
/// <summary>
/// A constructor which delegates to the base constructor to enable use of connection string.
/// </summary>
/// <param name='connectionstring`></param>
public <#= this.classname #>(string connectionstring) : base(connectionstring) {}
#endregion
}
}