我希望在我的TT文件中使用我自己在CS文件中定义的类。
示例:
示例:
public class ClassDefinition
{
public string NameSpace { get; set; }
public string Name { get; set; }
public string Protection { get; set; }
List<ClassProperty> Properties { get; set; }
}
我的TT看起来像:
<#@ template debug="true" hostspecific="true" language="C#" #>
<#@ output extension=".cs" #>
<#@ assembly name="System" #>
<#@ assembly name="System.Core" #>
<#@ assembly name="System.Xml"#>
<#@ import namespace="System.Xml" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ import namespace="System.IO" #>
<#@ include file="$(ProjectDir)ClassDefinition.cs" #>
<#
// Read the model file
XmlDocument doc = new System.Xml.XmlDocument();
doc.Load(this.Host.ResolvePath("GeneratedXmlFile.xml"));
IList<XmlNode> nodeList = new List<XmlNode>();
foreach (XmlNode node in doc.DocumentElement)
{
switch(node.Name)
{
case "Model":
{
ClassDefinition classDefinition = new ClassDefinition();
但是我遇到了这个错误信息:
编译转换:找不到类型或命名空间名称“ClassDefinition”(是否缺少using指令或程序集引用?)
我在网上查过并尝试了以下方法: - 使用include - 使用assembly - 使用USING 但是都没有起作用。
有什么想法吗?