如何使用 t4 模板编辑现有 class 模型?
how to edit existing class model with t4 template?
我有一个具有某些属性的 class 模型,需要在 set 部分添加一段代码:
class person
{
string _name;
public string Name
{
get
{
return _name;
// code
}
set
{
_name = value;
//adding here
}
}
// other properties
}
我如何使用 t4 模板做到这一点
你不能。 T4 将输出整个文件,从而替换之前存在的任何文本。
方法是在T4模板中生成整个class。
我有一个具有某些属性的 class 模型,需要在 set 部分添加一段代码:
class person
{
string _name;
public string Name
{
get
{
return _name;
// code
}
set
{
_name = value;
//adding here
}
}
// other properties
}
我如何使用 t4 模板做到这一点
你不能。 T4 将输出整个文件,从而替换之前存在的任何文本。 方法是在T4模板中生成整个class。