Ste*_*t_R 1 typescript typewriter
使用Typewriter .tst文件,可以使用$Properties([MyAttr])过滤器仅包含具有特定属性的属性.
像这样例如:
export class $Name{
$Properties([MyAttr])[
public $name: $Type = $Type[$Default];]
}
Run Code Online (Sandbox Code Playgroud)
是否可以包含除具有给定属性的属性之外的所有属性?
这样的事情可能是:
export class $Name{
$Properties(![TsIgnore])[ //but this doesnt work!!
public $name: $Type = $Type[$Default];]
}
Run Code Online (Sandbox Code Playgroud)
我已经试过了我能想到的![TsIgnore],[!TsIgnore]等等.但没有工作.在文档中也找不到任何内容
我实现了一个IsIncluded方法:
bool IsIncluded(Class c)
{
// exclude attributes
if(c.BaseClass?.FullName == "System.Attribute") return false;
return !ExcludeObjects.Any(ec => c.Name == ec || c.FullName == ec);
}
Run Code Online (Sandbox Code Playgroud)
在顶部的某个地方,我有这个:
static string[] ExcludeObjects = new string[]
{
"MyClassToExclude",
"Full.Namespace.Path.To.MyOtherClassToExclude",
};
Run Code Online (Sandbox Code Playgroud)
并且模板具有以下内容:
$Classes($IsIncluded)[ ... ]
Run Code Online (Sandbox Code Playgroud)
谢谢
| 归档时间: |
|
| 查看次数: |
1506 次 |
| 最近记录: |