本文整理汇总了C#中ITreeNode.GetTreeStartOffset方法的典型用法代码示例。如果您正苦于以下问题:C# ITreeNode.GetTreeStartOffset方法的具体用法?C# ITreeNode.GetTreeStartOffset怎么用?C# ITreeNode.GetTreeStartOffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITreeNode
的用法示例。
在下文中一共展示了ITreeNode.GetTreeStartOffset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetModifier
/// <summary>Gets the modifier.</summary>
/// <param name="treeNode">The element.</param>
/// <param name="classDeclaration">The class declaration.</param>
/// <returns>Returns the modifier.</returns>
private static string GetModifier(ITreeNode treeNode, IClassLikeDeclaration classDeclaration)
{
ITypeMemberDeclaration classMember = null;
var caret = treeNode.GetTreeStartOffset();
foreach (var typeMemberDeclaration in classDeclaration.MemberDeclarations)
{
if (typeMemberDeclaration.GetTreeStartOffset() > caret)
{
break;
}
classMember = typeMemberDeclaration;
}
var modifier = "public";
var accessRightsOwner = classMember as IAccessRightsOwner;
if (accessRightsOwner != null)
{
var rights = accessRightsOwner.GetAccessRights();
switch (rights)
{
case AccessRights.PUBLIC:
modifier = "public";
break;
case AccessRights.INTERNAL:
modifier = "internal";
break;
case AccessRights.PROTECTED:
modifier = "protected";
break;
case AccessRights.PROTECTED_OR_INTERNAL:
modifier = "protected";
break;
case AccessRights.PROTECTED_AND_INTERNAL:
modifier = "protected internal";
break;
case AccessRights.PRIVATE:
modifier = "private";
break;
case AccessRights.NONE:
modifier = string.Empty;
break;
}
}
var modifiersOwner = classMember as IModifiersOwner;
if (modifiersOwner != null)
{
if (modifiersOwner.IsStatic)
{
if (!string.IsNullOrEmpty(modifier))
{
modifier += ' ';
}
modifier += "static";
}
}
if (!string.IsNullOrEmpty(modifier))
{
modifier += ' ';
}
return modifier;
}