1
A
回答
2
下面的代碼的伎倆:
StreamReader reader = new StreamReader(@"..\..\demo.cs");
var tex = reader.ReadToEnd();
var syntaxTree = new CSharpParser().Parse(tex, tex);
var testClass = syntaxTree.Descendants.OfType<TypeDeclaration>().Single(x => x.ClassType == ClassType.Class);
var testClassAttributes = testClass.Attributes.SelectMany(x => x.Attributes).ToArray();
0
你可以用下面的方法:
IEnumerable<ICSharpCode.NRefactory.CSharp.Attribute> GetAttributes(TypeDeclaration typeDeclaration)
{
return typeDeclaration.Members
.SelectMany(member => member
.Attributes
.SelectMany(attr => attr.Attributes));
}
相關問題
- 1. 與類屬性
- 2. 屬性與父類相同的屬性
- 3. NRefactory缺少dll
- 4. Python類與模塊屬性
- 5. Ruby類與數組屬性
- 6. 抽象類與類類型屬性
- 7. 數據綁定類的屬性與屬性另一類
- 8. 類:屬性屬性
- 9. 空派生類與Vs類型屬性
- 10. 限制屬性類型與元類
- 11. Python類屬性/屬性
- 12. 類和屬性的屬性
- 13. jQuery的 - 屬性與屬性
- 14. Backbone.js - 屬性與屬性
- 15. 沒有超類屬性的類屬性
- 16. Python的類屬性與元類與類變量
- 17. NRefactory 5添加空行
- 18. xcode:property'title''copy'屬性與超類'UIViewController'屬性不匹配
- 19. 如何獲得與.NET屬性關聯的類/屬性/ etc?
- 20. 添加屬性類列表與特定屬性
- 21. C#檢查,如果屬性與屬性新類裏
- 22. 類型屬性類
- 23. 柔性結合的基類屬性與類繼承
- 24. 的Fortran SAVE屬性與隱式類型
- 25. 訪問類屬性與空間
- 26. Autofac兩個屬性與同類型
- 27. Woocommerce排序與「選擇」類型屬性
- 28. 的Grails:與非域類屬性
- 29. jaxb解組與其他類屬性
- 30. 旋轉與CSS類屬性圖標