本文整理汇总了C#中ICSharpCode.NRefactory.CSharp.EntityDeclaration.GetParent方法的典型用法代码示例。如果您正苦于以下问题:C# EntityDeclaration.GetParent方法的具体用法?C# EntityDeclaration.GetParent怎么用?C# EntityDeclaration.GetParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICSharpCode.NRefactory.CSharp.EntityDeclaration
的用法示例。
在下文中一共展示了EntityDeclaration.GetParent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetActionForLevel
CodeAction GetActionForLevel(RefactoringContext context, string accessName, Modifiers access, EntityDeclaration node, AstNode selectedNode)
{
return new CodeAction(context.TranslateString("To " + accessName), script => {
Modifiers newModifiers = node.Modifiers;
newModifiers &= ~Modifiers.VisibilityMask;
if (!(node is Accessor) || access != (node.GetParent<EntityDeclaration>().Modifiers & Modifiers.VisibilityMask)) {
//Do not add access modifier for accessors if the new access level is the same as the parent
//That is, in public int X { $private get; } if access == public, then the result should not have the modifier
newModifiers |= access;
}
script.ChangeModifier(node, newModifiers);
}, selectedNode);
}
示例2: GetActualAccess
static Modifiers GetActualAccess(AstNode parentTypeDeclaration, EntityDeclaration node)
{
Modifiers nodeAccess = node.Modifiers & Modifiers.VisibilityMask;
if (nodeAccess == Modifiers.None && node is Accessor) {
EntityDeclaration parent = node.GetParent<EntityDeclaration>();
nodeAccess = parent.Modifiers & Modifiers.VisibilityMask;
}
if (nodeAccess == Modifiers.None) {
if (parentTypeDeclaration == null) {
return Modifiers.Internal;
}
return Modifiers.Private;
}
return nodeAccess & Modifiers.VisibilityMask;
}