T4访问具有特定注释的属性列表

时间:2016-05-03 17:07:36

标签: c# t4

使用[key]注释访问t4文件属性,例如在ownedAttributes和navigableOwnedEnds

1 个答案:

答案 0 :(得分:2)

以下是我正在寻找的答案

foreach(IProperty attribute in this.Element.OwnedAttributes)
{
  string attributeList = GetProperty(attribute, "property", "ClrAttributes");
  if(!string.IsNullOrEmpty(attributeList))
  {
    //attributeList now will contain the attribute put in 
    //Streotypes>C# property>ClrAttributes
  }
}