本文整理汇总了C#中IDeclaredElement.GetDeclarations方法的典型用法代码示例。如果您正苦于以下问题:C# IDeclaredElement.GetDeclarations方法的具体用法?C# IDeclaredElement.GetDeclarations怎么用?C# IDeclaredElement.GetDeclarations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDeclaredElement
的用法示例。
在下文中一共展示了IDeclaredElement.GetDeclarations方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FromDeclaredElement
public static MemberWithAccess FromDeclaredElement(IDeclaredElement declaredElement)
{
Contract.Requires(declaredElement != null);
var clrDeclaredElement = declaredElement as IClrDeclaredElement;
if (clrDeclaredElement == null)
return null;
var accessRightsOwner = declaredElement as IAccessRightsOwner;
if (accessRightsOwner == null)
return null;
var declaringTypeAccessRights = declaredElement.GetDeclarations()
.FirstOrDefault()
.With(x => x.GetContainingNode<IClassLikeDeclaration>())
.With(x => (AccessRights?)x.GetAccessRights());
if (declaringTypeAccessRights == null)
return null;
return new MemberWithAccess(clrDeclaredElement, declaringTypeAccessRights.Value,
GetMemberType(declaredElement),
accessRightsOwner.GetAccessRights());
}
示例2: GetTextRange
static TextRange GetTextRange(IDeclaredElement field)
{
var declarations = field.GetDeclarations();
if (declarations.Count > 0)
{
return declarations[0].GetDocumentRange().TextRange;
}
return new TextRange();
}