通过ReSharper SDK访问IMethodDeclaration对象

时间:2013-06-26 01:51:16

标签: c# resharper resharper-7.1 resharper-plugins resharper-sdk

我手头有一个INamespaceBody,IClassDeclaration和IMethod。我想获得对应于IClassDeclaration的IMethod和IClassBody的IMethodDeclaration。但我完全不知所措......我怎么能做到这一点?

1 个答案:

答案 0 :(得分:1)

您可以在给定的IMethod上调用GetDeclarations()方法来获取IMethodDeclaration

IMethod method = MyGetMethod(); // Your code to get the IMethod.
// This returns a list of IDeclaration
var declaration = main.GetDeclarations();
IMethodDeclaration methodDeclaration = declaration[0];

至于从IClassDeclaration获取IClassBody,只需调用Body属性。